title: Merge 2 tables in SQL and save into 1 new table
body: <p>If we have two or more tables with the same columns</p>
  
  <p>Table 1</p>
  
  <pre><code>Structure, Name, Active
  1,A,1
  </code></pre>
  
  <p>Table 2</p>
  
  <pre><code>Structure, Name, Active
  2,B,0
  </code></pre>
  
  <p>We would like to combine these two tables and save it into a new one</p>
  
  <p>New Table </p>
  
  <pre><code>Structure, Name, Active
  1,A,1
  2,B,0
  </code></pre>
  
  <p>Here is the code</p>
  
  <pre><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 
  )
  </code></pre>
  
  <p>The following error message will show up</p>
  
  <blockquote>
    <p>Msg 156, Level 15, State 1, Line 10<br>
    Incorrect syntax near the keyword 'FROM'.</p>
  </blockquote>
  
  <p>The same thing if we use</p>
  
  <pre><code>SELECT * INTO Amide_actives_decoys
  FROM (
     SELECT * FROM Amide_decoys 
     UNION
     SELECT * FROM Amide_actives 
  )
  </code></pre>
  
  <p>Following this answer</p>
  
  <p><a href="https://stackoverflow.com/questions/18243507/joining-a-table-onto-itself-in-sql-and-saving-the-result">Joining a table onto itself in SQL and saving the result</a></p>
  
  <p>The error message will be</p>
  
  <blockquote>
    <p>Msg 102, Level 15, State 1, Line 5<br>
    Incorrect syntax near ';'. </p>
  </blockquote>
  
  <p>Could any guru kindly offer some comments?  Thanks!</p>