select * from person
declare PersonCur cursor for select name from person
open personcur
declare @c nvarchar(50)
fetch first from personcur into @c
print @c
close personcur
deallocate personcur
declare PersonCur cursor scroll for select name from person
open personcur
declare @c nvarchar(50)
fetch first from personcur into @c
print @c
declare PersonCur2 cursor scroll for select * from person
open personcur2
declare @id int
declare @name nvarchar(50)
declare @name2 nvarchar(50)
fetch relative -1 from personcur2 into @id,@name,@name2
print @id
print @name
print @name2
declare @id int
declare @name nvarchar(50)
declare @name2 nvarchar(50)
while @@FETCH_STATUS=0
begin
print @id
print @name
print @name2
fetch next from personcur2 into @id,@name,@name2
end
select @@FETCH_STATUS
close personcur2
deallocate personcur2