sql server游标:
--定义游标
declare cursor1 cursor for select ID,Name from A
--打开游标
open cursor1
declare @id int
declare @name varchar(50)
declare @n int
declare @i int=1
set @n=(select COUNT(1) from A)
while(@i<@n)
begin
set @i=@i+1
fetch next from cursor1 into @id,@name
select @id select @name
end
--关闭游标
close cursor1
--释放游标,释放后就不能在打开游标了
deallocate cursor1