Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/21.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
SQL Server 2012将表的数据复制到另一个表(新表中增加1列)_Sql_Sql Server_Sql Server 2012 - Fatal编程技术网

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;