----sqlserver游标使用
begin
declare @item_code varchar(32)--定义变量
declare @item_name varchar(32)
declare @invest_money_sum float
--定义游标
declare my_cursor cursor
for
select item_code,item_name,invest_money_sum from zftz_project_sheji_result
--打开游标
open my_cursor
fetch next from my_cursor into @item_code,@item_name,@invest_money_sum
while(@@fetch_status=0)
begin
update zftz_project_item_info1 set mainamount=@invest_money_sum where code=@item_code
fetch next from my_cursor into @item_code,@item_name,@invest_money_sum
endaa
--关闭游标
close my_cursor
deallocate my_cursor --卸载游标
end
begin
declare @item_code varchar(32)--定义变量
declare @item_name varchar(32)
declare @invest_money_sum float
--定义游标
declare my_cursor cursor
for
select item_code,item_name,invest_money_sum from zftz_project_sheji_result
--打开游标
open my_cursor
fetch next from my_cursor into @item_code,@item_name,@invest_money_sum
while(@@fetch_status=0)
begin
update zftz_project_item_info1 set mainamount=@invest_money_sum where code=@item_code
fetch next from my_cursor into @item_code,@item_name,@invest_money_sum
endaa
--关闭游标
close my_cursor
deallocate my_cursor --卸载游标
end