---声明和表中字段数量相同的变量
declare @a nvarchar(50)
declare @b nvarchar(50)
---创建游标
declare aaa cursor for select * from [dbo].[Company]
---打开游标
open aaa
---看一下
fetch next from aaa into @a,@b
---查看上一步操作是否成功
while(@@FETCH_STATUS=0)
begin
---取值等业务逻辑
print(@b)
---再看一下
fetch next from aaa
end
---关闭游标
close aaa
---释放游标
deallocate aaa
declare @a nvarchar(50)
declare @b nvarchar(50)
---创建游标
declare aaa cursor for select * from [dbo].[Company]
---打开游标
open aaa
---看一下
fetch next from aaa into @a,@b
---查看上一步操作是否成功
while(@@FETCH_STATUS=0)
begin
---取值等业务逻辑
print(@b)
---再看一下
fetch next from aaa
end
---关闭游标
close aaa
---释放游标
deallocate aaa