title: SQL Server / MySQL / Access - speeding up inserting many rows in an inefficient manner
body: <p><strong>SETUP</strong></p>
  
  <p>I have to insert a couple million rows in either SQL Server 2000/2005, MySQL, or Access.  Unfortunately I don't have an easy way to use bulk insert or BCP or any of the other ways that a normal human would go about this.  The inserts will happen on one particular database but that code needs to be db agnostic -- so I can't do bulk copy, or SELECT INTO, or BCP.  I can however run specific queries before and after the inserts, depending on which database I'm importing to.</p>
  
  <p>eg.</p>
  
  <pre><code>If IsSqlServer() Then
      DisableTransactionLogging();
  ElseIf IsMySQL() Then
      DisableMySQLIndices();
  End If
  
  ... do inserts ...
  
  If IsSqlServer() Then
      EnableTransactionLogging();
  ElseIf IsMySQL() Then
      EnableMySQLIndices();
  End If
  </code></pre>
  
  <p><strong>QUESTION</strong></p>
  
  <p>Are there any interesting things I can do to SQL Server that might speed up these inserts?</p>
  
  <p>For example, is there a command I could issue to tell SQL Server, "Hey, don't bother recording these transactions in the transaction log".</p>
  
  <p>Or maybe I could say, "Hey, I have a million rows coming in, so don't update your index until I'm totally finished".</p>
  
  <pre><code>ALTER INDEX [IX_TableIndex] ON Table DISABLE
       ... inserts
  ALTER INDEX [IX_TableIndex] ON Table REBUILD
  </code></pre>
  
  <p>(Note: Above index disable only works on 2005, not 2000.  Bonus points if you know a way to do this on 2000).</p>
  
  <p>What about MySQL, and Access?</p>