标签:close 打开 arch 关闭 cursor 定义 count int end
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
标签:close 打开 arch 关闭 cursor 定义 count int end
原文地址:http://www.cnblogs.com/tony-brook/p/7803286.html