create proc #fc (@c cursor varying output)
as
declare @e int, @l nvarchar(10)
set @c = cursor scroll
for select employeeid, lastname from northwind..employees order by employeeid
open @c
while(1=1)
begin
fetch next from @c into @e, @l
if @@fetch_status < 0 break
print 'E: ' + str(@e) + ', L: ' + @l
end
go
declare @e int, @l nvarchar(10), @n int, @c cursor
exec #fc @c output
print ''
print 'r f again'
fetch first from @c
print 'r last '
fetch last from @c
print 'r 5th from b'
fetch absolute 5 from @c
print 'r 2 from c'
set @n = -2
fetch relative @n from @c
deallocate @c
This page was last updated on May 01, 2006 04:28 PM.