游标的问题,麻烦高手看下
Alter proc pro_getName
as
declare @name varchar(200)
declare mycursor cursor Scroll for select mtvnam from mtv v where v.mtvtyp='来源'
open mycursor
fetch next from mycursor into @name;
while(@@FETCH_STATUS=0)
begin
print @name
end
close mycursor
deallocate mycursor
exec pro_getName 发现是个死循环,查询只是9条数据,为什么那?
还有就是sql中循环有几种写法?麻烦举个例子,谢谢
[解决办法]
Alter proc pro_getNameasdeclare @name varchar(200)declare mycursor cursor Scroll for select mtvnam from mtv v where v.mtvtyp='来源'open mycursorfetch next from mycursor into @name;while(@@FETCH_STATUS=0)beginprint @name------------这里是少了的fetch next from mycursor into @name;------------这里是少了的endclose mycursordeallocate mycursor
[解决办法]