将表specialcarorder中的ordercode字段更新为自增的数
declare @bid int
declare @wincode int
set @wincode=900001
declare cur cursor
read_only
for select id from specialcarorder where activetype=8182
open cur
fetch next from cur into @bid
while(@@fetch_status=0)
begin
update specialcarorder set ordercode=@wincode where id=@bid
set @wincode=@wincode+1
fetch next from cur into @bid
end
close cur
deallocate cur

SQL利用游标遍历更新数据-LMLPHP
12-16 23:04