title: Combining n DataTables into a Single DataTable
body: <p>All, there are some question on this, but I can't seem to extract enough information to solve the problem for my case. I extract an unknown number of tables into SQL Server 'Tab1', 'Tab2', 'Tab3', ... , 'TabN'. The columns in these tables are different, but the row definitions are the same. I need to pull all the data in from the Server into N <code>DataTable</code>s and then combine these to form a single <code>DataTable</code>. What I do currently is</p>
  
  <pre><code>int nTmpVolTabIdx = 1;
  strSqlTmp = String.Empty;
  using (DataTable dataTableALL = new DataTable())
  {
      while (true)
      {
          string strTmpVolName = String.Format("Tab{0}", nTmpVolTabIdx);
          strSqlTmp = String.Format("SELECT * FROM [{0}];", strTmpVolName);
  
          // Pull the data from 'VolX' into a local DataTable.
          using (DataTable dataTable = UtilsDB.DTFromDB(conn, strTmpVolName, strSqlTmp, false))
          {
              if (dataTable == null)
                  break;
              else
                  dataTableALL.Merge(dataTable);
          }
          nTmpVolTabIdx++;
      }
      ...
  }
  </code></pre>
  
  <p>This merges the <code>DataTable</code>s but they are miss-aligned (padding blank cells onto the appended data set). I could append the columns of the new <code>DataTable</code> via a loop; <strong>but is there an easier/nicer way to do this (perhaps using LINQ)?</strong></p>
  
  <p>Thanks for your time.</p>
  
  <p><em>Edit. To provide the example data sets.</em></p>
  
  <p><em>What I required is</em></p>
  
  <p><img src="https://i.stack.imgur.com/99Zg2.png" alt="Full DataTable"></p>
  
  <p><em>The individual tables are</em> </p>
  
  <p><img src="https://i.stack.imgur.com/unqS9.png" alt="Tabs"></p>
  
  <p><em>After the first Merge operation I have the following</em> </p>
  
  <p><img src="https://i.stack.imgur.com/qMICw.png" alt="After Merge"></p>
  
  <p><em>Thanks again.</em></p>