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

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

你可能感兴趣的:(sqlserver)