其他分享
首页 > 其他分享> > 游标

游标

作者:互联网

--SELECT * FROM Students

declare mycursor cursor for
select * from Students

open mycursor
declare @Id int, @Name nvarchar(20), @Age int, @Sex bit, @Flag bit;
fetch next from mycursor into @id,@name,@age,@sex,@flag    

while @@FETCH_STATUS = 0
begin    
    select @Id,@name
    fetch next from mycursor into @id,@name,@age,@sex,@flag    
end
close mycursor

deallocate mycursor

 

标签:name,int,into,游标,sex,mycursor,id
来源: https://www.cnblogs.com/superfeeling/p/12597097.html