遇到一个游标的BUG

sxq129601 2020-01-08 03:22:58
declare user_cur cursor for select .... --这里能够查询到10条记录
declare @xxx nvarchar(2000)
begin
open user_cur
while @@fetch_status=0
begin
fetch next from user_cur into @XXX
print(@XXX) --只打印了5个,还有5个莫名失踪了,也没报错
fetch next from user_cur into @XXX
end
close user_cur
deallocate user_cur
end
...全文
72 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
唐诗三百首 2020-01-08
  • 打赏
  • 举报
回复

declare user_cur scroll cursor for 
  select ....             --这里能够查询到10条记录
declare @xxx nvarchar(2000)

begin
open user_cur 
fetch first from user_cur into @XXX
while @@fetch_status=0 
begin
   print(@XXX)
   fetch next from user_cur into @XXX
end
close user_cur 
deallocate user_cur
end
顺势而为1 2020-01-08
  • 打赏
  • 举报
回复


declare user_cur cursor  for  select ....             --这里能够查询到10条记录
declare @xxx nvarchar(2000)
begin
open user_cur 
   fetch next from user_cur into @XXX

while @@fetch_status=0 
begin
    fetch next from user_cur into @XXX
   print(@XXX)                --只打印了5个,还有5个莫名失踪了,也没报错
end
close user_cur 
deallocate user_cur
end



顺势而为1 2020-01-08
  • 打赏
  • 举报
回复
fetch next from user_cur into @XXX 写了两个


   fetch next from user_cur into @XXX
print(@XXX)                --只打印了5个,还有5个莫名失踪了,也没报错
   fetch next from user_cur into @XXX


22,210

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧