创建表:

澳门葡亰娱乐场手机版 1澳门葡亰娱乐场手机版 2

1 1 create table tb1(
2 2 
3 3 id int ,
4 4 
5 5 name nvarchar(20)
6 6 
7 7 )

View Code


开创再次回到游标的存放进度:

澳门葡亰娱乐场手机版 3澳门葡亰娱乐场手机版 4

 1 create proc tb1_proc (
 2 
 3 @cur cursor varying output
 4 
 5 )
 6 
 7 as
 8 
 9 begin
10 
11   set @cur=cursor for
12 
13   select * from tb1
14 
15 end
16 
17 open @cur

澳门葡亰娱乐场手机版,View Code


 使用存款和储蓄进程再次来到的游标:

澳门葡亰娱乐场手机版 5澳门葡亰娱乐场手机版 6

 1 declare @my_cur cursor
 2 
 3 declare @id int, @name nvarchar(20)
 4 
 5 exec tb1_proc @my_cur output
 6 
 7 --open @cursor    -- @cursor already opened
 8 
 9 fetch next from @my_cur into @id, @name
10 
11 while(@@fetch_status=0)
12 
13   begin
14 
15     print '编号:' + convert(nvarchar,@id)
16 
17     print '姓名:' + @name
18 
19     print '......................'
20 
21     fetch next from @my_cur into @id, @name
22 
23   end

View Code

 注意:存款和储蓄进度中开创游标后要开垦