排名
6
文章
6
粉丝
16
评论
8
{{item.articleTitle}}
{{item.blogName}} : {{item.content}}
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2024TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术
分类:
SQL
存在一张测试表
if exists(select * from sys.tables where name ='test')
drop table test
CREATE table test(
id int,
name varchar(50),
address varchar(50))
insert into test values(2,'aa','address1')
insert into test values(3,'bb','address2')
insert into test values(5,'cc','address3')
insert into test values(8,'dd','address4')
insert into test values(11,'ee','address5')
此表中Id 是不连续的
;with cte(rownum,id) as(
select ROW_NUMBER()over(order by id),id from test
)
update test set id= rownum from cte as t1 where test.id = t1.id
将行号替换成原本的Id
现在的Id 连续起来了
积累一个小技巧,日后总会用到
评价