title: VBA: Import table from Excel into SQL
body: <p>I am trying to import a data table from excel into SQL Server 2012, using VBA.<br>
  Preferably with help of a UDF.</p>
  
  <p>The excel table looks something like this.</p>
  
  <pre><code>TableID    2012  2011  2010  2009
  row 1       11     12   13    14
  row 2       21     22   23    24
  row 3       31     32   33    34
  etc..
  </code></pre>
  
  <p>(I placed the numbers in the cells to designated their position. For example 11 = row 1, column 1)</p>
  
  <p>The database table looks something like this.</p>
  
  <pre><code>Header:        id   |  year  |  row1  |  row2  |  row3  |  etc..
  ExampData:  TableId    2012      11       21       31       ..
  ExampData:  TableId    2011      12       22       32       ..
  </code></pre>
  
  <p>(This doesn't include the Primary Key column, which can be either a combination of id and year, or a <code>NEWID()</code>)</p>
  
  <hr>
  
  <p>I know how to import specific columns, for example I could run the following code:</p>
  
  <pre><code>INSERT INTO example_table (id, year, row1, row2, row3) VALUES ('001', '2012', '11', '21', '31')
  </code></pre>
  
  <p>This works great for individual columns, but how would I go about making it work for the entire table (multiple columns and rows).</p>