如果不关闭游标,就会
消息 16915,级别 16,状态 1,过程 (过程名),第 xx 行 名为 'c1' 的游标已存在。 消息 16905,级别 16,状态 1,过程 (过程名),第 xx 行 游标已打开。
如何关闭游标,其实和定义游标和打开游标是对应的,sql如下:
declare c1 cursor for -- 定义游标 select record_id from cis_cp_occ_main where enc_id=@enc_id open c1 -- 打开游标 fetch next from c1 into @ids while @@FETCH_STATUS=0 begin update table set table.a='1' where ...... fetch next from c1 into @ids end close c1 --关闭游标 deallocate c1 -- 释放游标