sql游標用法示例

2021-06-02 11:25:17 字數 444 閱讀 4278

declare @ida smalldatetime

declare @icd int

declare s_cursor cursor for

select date,cid from dayrecomstat  group by date order by date

open s_cursor

fetch next from s_cursor into @ida,@icd ;

while @@fetch_status = '000000' --游標結束標誌

begin 

exec [proc_imeisnewuvinsert] @ida,@icd

fetch next from s_cursor into @ida,@icd;

endclose s_cursor

deallocate s_cursor

SQL游標示例

declare userid char 6 declare username varchar 20 declare email varchar 200 declare testcur cursor for select userid,username,email from tbusercommon ...

SQL 游標示例

1 declare iint 2declare teststr varchar 50 3 set i 0 給初始值45 create table temp test 建立臨時表6 7 num varchar 50 8 9while i 10 10begin 11insert into temp te...

sql 游標用法一

declare mergedate datetime declare masterid int declare duplicateid int select mergedate getdate declare merge cursor cursor fast forward for select m...