Sql Server 2008游标使用

时间:2021-12-21 13:26:54
 1 declare @ssl_id uniqueidentifier;
 2 declare @ssl_JieSHM varchar(2000);
 3 declare @ssl_FanHZFC varchar(2000);
 4 declare @ssl_FaSRQ datetime;
 5 declare @ssl_JieGuo nvarchar(200);
 6 declare @errno int ;
 7 declare B_Cursor cursor for  select ssl_id,ssl_JieSHM,ssl_FaSRQ from SMSSendLog 
 8     open B_Cursor;
 9         fetch next from B_Cursor into @ssl_id ,@ssl_JieSHM,@ssl_FaSRQ
10         
11         --Begin TransAction
12         select '123';
13         while @@FETCH_STATUS =0 
14            begin
15                set @ssl_JieGuo='发送成功!';
16                set @ssl_FanHZFC='num=1&success='+@ssl_JieSHM+'&faile=&err=发送成功!&errid=0'; 
17                select  @ssl_FanHZFC;
18                insert into SMSSendResult values(NEWID(), @ssl_id,@ssl_FaSRQ,@ssl_JieSHM,@ssl_FanHZFC,@ssl_JieGuo)
19                fetch next from B_Cursor into @ssl_id ,@ssl_JieSHM,@ssl_FaSRQ
20            end
21    close B_Cursor;
22 deallocate B_Cursor;