MSSQL修改已有数据的表的自增列

来源:这里教程网 时间:2026-03-02 11:06:15 作者:
use demo
go


create table testid
([ID] [bigint] IDENTITY(1,1) NOT NULL,
col1 varchar(100),
[TMSTAMP] [timestamp] NOT NULL)




insert into testid(col1) values ('a')
insert into testid(col1) values ('b')
insert into testid(col1) values ('c')




create table testid2
([ID] [bigint] IDENTITY(1,1) NOT NULL,
col1 varchar(100),
[TMSTAMP] [timestamp] NOT NULL)


insert into testid2(col1) select col1 from testid
set IDENTITY_INSERT testid2 OFF


select * from testid2

相关推荐