悉野小楼

导航

SqlServer游标

 

declare @id int
declare my_cursor cursor
for 
select id from mytable
open my_cursor
fetch next from my_cursor into @id
while(@@fetch_status=0)
begin
print @id
fetch next from my_cursor into @id
end
close my_cursor
deallocate my_cursor

定义游标, 打开游标, 关闭游标, 清除游标

posted on 2012-12-20 12:08  悉野  阅读(156)  评论(0编辑  收藏  举报