title: How to copy large number of data from one table to another in same database?
body: <p>I have two tables with same column structure in the same database: <code>TableA</code> and <code>TableB</code>.</p>
  
  <p><code>TableA</code> doesn't have any indexes, but <code>TableB</code> has a non-clustered unique index.</p>
  
  <p><code>TableA</code> has 290 Million rows of data that needs to be copied to <code>TableB</code>.</p>
  
  <p>As they both have same structure, I've tried</p>
  
  <pre><code>INSERT INTO TableB 
      SELECT * 
      FROM TableA;
  </code></pre>
  
  <p>It was executing for hours and produced a huge log file that filled the disk. As a result the disk ran out of space and the query was killed.</p>
  
  <p>I can shrink the log file. How can I copy these many rows of data to another table efficiently?</p>