sqlserver存取过程-游标
Posted 永远相信美好的事情即将发生
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了sqlserver存取过程-游标相关的知识,希望对你有一定的参考价值。
ALTER proc [dbo].[common_proc_temp2]
as begin
declare @id varchar(50);
declare @cbcontractid varchar(50);
declare @xh int ;
declare owner_03_cursor cursor scroll
for select id from cb_contract where canton_id like ‘20%‘
--2.打开游标
open owner_03_cursor
fetch next from owner_03_cursor into @cbcontractid --into的变量数量必须与游标查询结果集的列数相同
while @@fetch_status=0 --提取成功,进行下一条数据的提取操作
begin
set @xh=1
declare owner_04_cursor cursor scroll
for select id from cb_contract_change where [email protected] order by bgrq asc
open owner_04_cursor
fetch next from owner_04_cursor into @id
while @@fetch_status=0
begin
update cb_contract_change set [email protected] where [email protected]
set @[email protected]+1;
fetch next from owner_04_cursor into @id
end
close owner_04_cursor;
deallocate owner_04_cursor;
fetch next from owner_03_cursor into @cbcontractid --移动游标
end
close owner_03_cursor;
deallocate owner_03_cursor;
end;
以上是关于sqlserver存取过程-游标的主要内容,如果未能解决你的问题,请参考以下文章