22,207
社区成员
发帖
与我相关
我的任务
分享
create table t1(id int identity,a int)
insert t1 values(1)
insert t1 values(2)
dbcc checkident ( 't1', reseed,1)
insert t1 values(3)
select * from t1
insert into cityt(code) select code from province where id=18
SET IDENTITY_INSERT cityt ON
insert into cityt(id,code) select id,code from province where id not in(select id from cityt)
SET IDENTITY_INSERT cityt OFF
如果确实重复,就用distinct
insert into cityt(id,code) select distinct id,code from province where id=18