读书人

游标不会循环是咋回事啊

发布时间: 2012-03-09 16:54:57 作者: rapoo

游标不会循环是怎么回事啊?
上次也碰到了这种问题
不知道是怎么回事
该检查哪里呢?

[解决办法]
while @@fetch_status
begin
fetch cursorname into @变量
end
[解决办法]
fetch next @cursorname
[解决办法]
用下面的格式,在while 之前要取一次
declare i cursor for xxxxxxxx
open i
declare @a varchar(50)
fetch next from i into @a
while (@@fetch_status=0)
begin
fetch next from i into @a
end
close i
deallocate i

读书人网 >SQL Server

热点推荐