SQL SERVER 游标循环读取表数据
declare @a varchar(50),@b int;
--定义游标
declare tempIndex cursor for (SELECT a, b from Bdc_Point)
--打开游标
open tempIndex
--抓取下一行数据给变量,一个或者多个
fetch next from tempIndex into @x, @y
--进行循环,0表示抓取成功,1表示抓取失败,2表示不存在抓取行
while @@fetch_status=0
begin
-- todo
print @x
fetch next from tempIndex into @x,@y
end
close tempIndex --关闭游标
deallocate tempIndex --释放游标