利用游标修改、删除数据

declare auth_cur cursor scroll for

select au_id, au_lname, au_fname, state

from authors for update of au_lname

open auth_cur

declare @rowcount int

set @rowcount = 6

fetch absolute @rowcount from auth_cur  --将变量@rowcount标识的行设置为当前行

--下面1行是利用游标进行修改操作

update authors set au_lname='' where current of auth_cur --修改游标中的当前行

--下面1行是利用游标进行删除操作

delete from authors where current of auth_cur

posted @ 2018-03-30 14:56  WhiteSpace  阅读(762)  评论(0编辑  收藏  举报