title: Best way to update 40 million rows in batch
body: <p>Basically I need to run this on a table with 40 million rows, updating every row at once will crash, so I want to batch the query so that if it crash, it can re-run the query and it would skip the finished batch and just continue with the ones left over.</p>
  
  <pre><code>UPDATE [table]
  SET [New_ID] = [Old_ID]
  </code></pre>
  
  <p>What is the fastest way to do this?  Here is how the table is created:</p>
  
  <pre><code>CREATE TABLE [table](
      [INSTANCE_ID] [int] NOT NULL,
      [table_ID] [bigint] IDENTITY(1,1) NOT NULL,
      [old_ID] [bigint] NOT NULL,
      [new_ID] [bigint] NOT NULL,
      [owner_ID] [int] NOT NULL,
      [created_time] [datetime] NULL
  ) ON [PRIMARY]
  </code></pre>
  
  <p>There are also indexes on created_time, owner_ID.</p>
  
  <p>EDIT:  My update statement is EXACTLY as shown, I literally just need to copy every entry in old_id into new_id for 40 million rows.</p>