游标

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

 

posted on 2020-03-30 10:46  静以修身俭以养德  阅读(122)  评论(0编辑  收藏  举报

导航