把某一字段更新为连续值的SQL

时间:2023-03-09 19:18:45
把某一字段更新为连续值的SQL
 --从10001起,借用生成的行号,批量编号表记录

 declare @start int = 10000;

 update t1 set t1.newNo=t2.newNo
from student t1
join (select id, (row_number() over(order by id) + @start) newNo from student) t2
on t1.id=t2.id

相关文章