打印本文 打印本文 关闭窗口 关闭窗口
SQL Server 2000游标使用方法
作者:武汉SEO闵涛  文章来源:敏韬网  点击数839  更新时间:2007/11/14 12:55:57  文章录入:mintao  责任编辑:mintao

游标使用方法:
use db1
declare my_cursor cursor scroll dynamic /*scroll表示可随意移动游标指针(否则只能向前),dynamic表示可以读写游标(否则游标只读)*/
for
select 姓名 from 个人资料

open my_cursor
declare @name sysname
fetch next from my_cursor into @name
while(@@fetch_status=0)
  begin
    print ''''姓名: '''' + @name
    fetch next from my_cursor into @name
  end
fetch first from my_cursor into @name
print @name
/* update 个人资料 set 姓名=''''zzg'''' where current of my_cursor */
/* delete from 个人资料 where current of my_cursor */
close my_cursor
deallocate my_cursor
正文 

打印本文 打印本文 关闭窗口 关闭窗口