好的,我在文件中找到了其他人编写的以下代码。我的问题是,这是否真的像我认为的那样工作,你必须在 MSSQL 的语法中的某处包含“FOR UPDATE OF”或“WHERE CURRENT OF”
set @group_id_new = (select max(group_id) + 1 from x_dc_multgroups_stage001c)
declare cur_cont cursor for
(select cont_id from x_dc_multgroups_stage002b)
open cur_cont
fetch next from cur_cont into @cont_id
while @@fetch_status = 0
begin
--print @cont_id
update x_dc_multgroups_stage002a
set group_id_new = @group_id_new
where group_id in (select group_id from x_dc_multgroups_stage002a where cont_id = @cont_id)
set @group_id_new = @group_id_new + 1
fetch next from cur_cont into @cont_id
end
close cur_cont
deallocate cur_cont