首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

游标的有关问题,麻烦高手看上

2012-09-06 
游标的问题,麻烦高手看下Alter proc pro_getNameasdeclare @name varchar(200)declare mycursor cursor Sc

游标的问题,麻烦高手看下


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中循环有几种写法?麻烦举个例子,谢谢

[解决办法]

SQL code
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
[解决办法]
探讨
Alter proc pro_getName
as
declare @name varchar(200)
declare @where varchar(200)
declare mycursor cursor Scroll for select mtvnam from mtv v where v.mtvtyp='来源'
open mycursor
fetch next from myc……

热点排行