从一个表导入数据到另外一个表,但不带自增列。

use wison
create table a(id int identity(1,1),name varchar(10))

insert into a select 'wison'

select * into b_a from a

此时,b_a表中的id仍然是自增列。

此时,我们可以采取另外一个方法,来使得目的表不包含自增列。

select * into without_id from a
union all
select * from a where 1 = 0

此时,可以看到WithOut_Id表的ID列已经没有自增列了。

具体的讨论,可以参考http://dba.stackexchange.com/questions/916/how-do-i-copy-a-table-with-select-into-but-ignore-the-identity-property

原文地址:https://www.cnblogs.com/Wison-Ho/p/3715474.html