Sql Server:Cursor的例子

来源:互联网 发布:sqlserver安装polybase 编辑:程序博客网 时间:2024/05/18 02:48
use northwind
declare @CategoryId int,@CategoryName varchar(50)
declare myCursor cursor for select CategoryId,CategoryName from Categories
open myCursor
fetch next from myCursor into @CategoryId,@CategoryName
while @@fetch_status=0
  begin
    print 'CategoryId='+cast(@CategoryId as varchar(4))
    print 'CategoryName='+@CategoryName
    print replicate('-',30)
    fetch next from myCursor into @CategoryId,@CategoryName
  end
close myCursor
deallocate myCursor
 
原创粉丝点击