title: How to append tables "Sideways" in SQL
body: <p>What i have is approximately 15 tables, each with about 10 columns and almost 1 million rows of data.</p>
  
  <p>All the 15 tables have the same primary keys I can use to join them by.</p>
  
  <p>For example..<br>
  Table 1 - Columns A B C D E <br>
  Table 2 - Columns A B F G H <br>
  Table 3 - Columns A B I J K <br>
  Table 4 - Columns A B L M N <br>
  etc.. where A &amp; B are the primary keys</p>
  
  <p>What I need would be one huge table that looks like this.. <br>
  mainTable - Columns A B C D E F G ... M N</p>
  
  <p>Right now, what I have done is:<br>
  - Start off with Table 1 as my "main" table <br>
  - Alter the table to add all the columns.. (i.e. F G H .. L M N)<br>
  - use an UPDATE command to fill in the "main" table<br></p>
  
  <pre><code>update mainTable set 
   F = a.F,
   G = a.G,
   H = a.H
  from mainTable left join Table2 a on
  mainTable.A = a.A  and 
  mainTable.B = a.B 
  
  (rinse and repeat for each of the 15 tables)
  </code></pre>
  
  <p>This seems to work, just that it's horribly inefficient. It takes ages to join just one table..</p>
  
  <p>Is there an alternative/faster method of performing this task?</p>