有没有创建游标来循环遍历一堆记录的经验?如果你有,你能给我提供一个基本的例子吗?谢谢
发布于 2012-08-08 11:11:54
declare cur cursor for
select id from tbl
open cur
declare @id int
fetch next from cur into @id
while (@@FETCH_STATUS = 0)
begin
print(@id)
fetch next from cur into @id
end
close cur
deallocate cur
-- just replace "tbl" with your table name and "id" with your field name
-- and do whatever you want in begin-end block (now it simply prints the id of each record)
https://stackoverflow.com/questions/11856518
复制相似问题