select * into tmp from t
//将数据放入临时表
alter table t drop column id
alter table t add id int identity(1,1)
set identity_insert t on
insert into t(id,col1,col2) select id,col1,col2 from tmp
//这里不能用*,要指定列才行
set identity_insert t off
drop table tmp
将已有列改为自增列
最新推荐文章于 2021-05-21 19:16:59 发布