ID的插入

如果想让ID也要与源表一样,则要把IDENTITY_INSERT打开。
但以下两句,前面不行,后者可以,原因可能在于:还必须显式地将字段列出
truncate table dorm
go
set IDENTITY_INSERT dorm ON
go
insert into dorm select * from manpower.dbo.dorm
go
insert into dorm(ID,em_code,dorm_code,valid_date,meno)
  select ID,em_code,dorm_code,valid_date,meno from manpower.dbo.dorm
go
set IDENTITY_INSERT dorm OFF
go

你可能感兴趣的:(id)