游标

--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

 

上一篇:队列的链式存储(C语言实现)


下一篇:sqlserver游标概念与实例全面解说