If we have two or more tables with the same columns
Table 1
Structure, Name, Active
1,A,1
Table 2
Structure, Name, Active
2,B,0
We would like to combine these two tables and save it into a new one
New Table
Structure, Name, Active
1,A,1
2,B,0
Here is the code
CREATE TABLE Amide_actives_decoys
(
Structure NVARCHAR(255),
Name NVARCHAR(255),
Active INT
)
GO
INSERT Amide_actives_decoys
FROM (
SELECT * FROM Amide_decoys
UNION
SELECT * FROM Amide_actives
)
The following error message will show up
Msg 156, Level 15, State 1, Line 10
Incorrect syntax near the keyword 'FROM'.
The same thing if we use
SELECT * INTO Amide_actives_decoys
FROM (
SELECT * FROM Amide_decoys
UNION
SELECT * FROM Amide_actives
)
Following this answer
Joining a table onto itself in SQL and saving the result
The error message will be
Msg 102, Level 15, State 1, Line 5
Incorrect syntax near ';'.
Could any guru kindly offer some comments? Thanks!