--聲明遊標
declare my_cursor cursor for select * from info
--刪除遊標資源
deallocate my_cursor
--開啟遊標,在遊標關閉或刪除前都有效
open my_cursor
--關閉遊標
close my_cursor
--聲明局部變數
declare @id int,@name varchar(20),@address varchar(20)
--定位到指定位置的記錄
fetch absolute 56488 from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address
--定位到目前記錄相對位置記錄
fetch relative -88 from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address
--定位到目前記錄前一條
fetch prior from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address
--定位到目前記錄後一條
fetch next from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address
--定位到首記錄
fetch first from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address
--定位到尾記錄
fetch last from my_cursor into @id,@name,@address
select @id as id,@name as name,@address as address