DECLARE @i int;
set @i=0
DECLARE authors_cursor CURSOR OPTIMISTIC DYNAMIC FOR
select id from customer
declare @new int
OPEN authors_cursor
FETCH authors_cursor into @new
WHILE(@@FETCH_STATUS = 0)
BEGIN
set @i = @i + 1
update table set id=@i where id=@new
FETCH authors_cursor into @new
endCLOSE authors_cursor
DEALLOCATE authors_cursorselect * from contect
set @i=0
DECLARE authors_cursor CURSOR OPTIMISTIC DYNAMIC FOR
select id from customer
declare @new int
OPEN authors_cursor
FETCH authors_cursor into @new
WHILE(@@FETCH_STATUS = 0)
BEGIN
set @i = @i + 1
update table set id=@i where id=@new
FETCH authors_cursor into @new
endCLOSE authors_cursor
DEALLOCATE authors_cursorselect * from contect
set @i=0
DECLARE authors_cursor CURSOR OPTIMISTIC DYNAMIC FOR
select * from customer
for update of 要更新的列OPEN authors_cursor
FETCH FIRST FROM authors_cursor
WHILE(@@FETCH_STATUS = 0)
BEGIN
set @i = @i + 1
UPDATE customer SET 要更新的列=123 WHERE CURRENT OF authors_cursor--更新该游标所在行
FETCH NEXT FROM authors_cursor
endCLOSE authors_cursor
DEALLOCATE authors_cursor