如果不關閉游標,就會
消息 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 -- 釋放游標
