I want to copy some columns from one table to another table at the same time. This is my query :
我想同时将一些列从一个表复制到另一个表。这是我的查询:
INSERT INTO [db_new].[dbo].[Element](Number, ElementNumber)
SELECT (NUMBER, ELEMENTNUMBER)
FROM [db_old].[dbo].[ELEMENTS]
I get this error for this query :
我收到此查询的错误:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near ','.消息102,级别15,状态1,行1','附近的语法不正确。
How can I safely copy multiple columns at the same time? Thanks.
如何安全地同时复制多个列?谢谢。
2 个解决方案
#1
The correct syntax is:
正确的语法是:
INSERT INTO [db_new].[dbo].[Element] (Number, ElementNumber)
SELECT NUMBER
,ELEMENTNUMBER
FROM [db_old].[dbo].[ELEMENTS]
#2
For this operation you need use select as a standard query as below
对于此操作,您需要使用select作为标准查询,如下所示
INSERT INTO [db_new].[dbo].[Element](Number,ElementNumber)
SELECT NUMBER, ELEMENTNUMBER FROM [db_old].[dbo].[ELEMENTS]
#1
The correct syntax is:
正确的语法是:
INSERT INTO [db_new].[dbo].[Element] (Number, ElementNumber)
SELECT NUMBER
,ELEMENTNUMBER
FROM [db_old].[dbo].[ELEMENTS]
#2
For this operation you need use select as a standard query as below
对于此操作,您需要使用select作为标准查询,如下所示
INSERT INTO [db_new].[dbo].[Element](Number,ElementNumber)
SELECT NUMBER, ELEMENTNUMBER FROM [db_old].[dbo].[ELEMENTS]