SQL Server 2012将表的数据复制到另一个表(新表中增加1列)
我想将一个表的数据复制到另一个表中,但新表有一个额外的列,我想在其中添加一个静态文本SQL Server 2012将表的数据复制到另一个表(新表中增加1列),sql,sql-server,sql-server-2012,Sql,Sql Server,Sql Server 2012,我想将一个表的数据复制到另一个表中,但新表有一个额外的列,我想在其中添加一个静态文本表名您可以使用插入。选择: insert into another_one(col1, col2, . . . , newcol) select col1, col2, . . . , 'newvalue' from atable; 这允许您向新列或多个列添加任何您喜欢的值 如果新表不存在,则使用选择进入: select col1, col2, . . . , 'newvalue' as new
表名您可以使用插入。选择
:
insert into another_one(col1, col2, . . . , newcol)
select col1, col2, . . . , 'newvalue'
from atable;
这允许您向新列或多个列添加任何您喜欢的值
如果新表不存在,则使用选择进入:
select col1, col2, . . . , 'newvalue' as newcol
into another_one
from atable;