1)定义游标
declare 游标名(cur_Youbiao) cursor fast_forward for select * from 表名 --fast_forward 最快的游标
2)打开游标
open 游标名(cur_Youbiao)
2.1)对游标的操作
--将每条数据读取并输出
--2.1.1将游标向后移动一条
fetch next from 游标名(cur_Youbiao)
--将游标循环向后移动,知道末尾
while @@fetch_status=0 --返回上一条
fetch语句执行的状态,表示成功begin
fetch next from 游标名(cur_Youbiao)
end
3)关闭游标
close 游标名(cur_Youbiao)
4)释放游标
deallocate 游标名(cur_Youbiao)