游标使用方法: 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 正文