一、SqlServer游标使用案例:
begin
declare @id int;
--声明游标
declare templist cursor for select id from PatchRecord
where busyid=0;
--打开游标
open templist;
--循环读取数据
fetch next from templist into @id;
while @@FETCH_STATUS=0 --如果检索到了数据继续循环
begin
print @id;
fetch next from templist into @id;
end
close templist;--关闭游标
deallocate templist;--释放游标
end;
更多:
SqlServer 游标(一)
SqlServer数据查找距离指定坐标附近的数据(一)
SqlServer 触发器使用整理(一)