title: Restoring sql table including identity column
body: <p>We had a few tables have their data get deleted.</p>
  
  <p>Now I have a copy database running where we were able to restore the lost data.  This is running in the same server instance. </p>
  
  <p>However, the id columns are now out of sync. As some rows have obviously been deleted over time etc and so for example row 98 in the new table data is 98.  But maybe 101 in the old table. </p>
  
  <p>Is it possible to copy all the data from the table across including the id? Or can I turn identity off from the column. Inert the data and then turn it back on. </p>
  
  <p>I have tried the following code;</p>
  
  <pre><code>Truncate Table DEV_DB.dbo.UserNames 
  Go
  
  Set Identity_Insert DEV_DB.dbo.UserNames On
  
      Insert Into DEV_DB.dbo.UserNames
      Select * From LIVE_DB.dbo.UserNames
  
  Set Identity_Insert DEV_DB.dbo.UserNames Off
  </code></pre>
  
  <p>However I get the error</p>
  
  <blockquote>
  <pre><code>Msg 8101, Level 16, State 1, Line 6
  </code></pre>
    
    <p>An explicit value for the identity column in table 'DEV_DB.dbo.UserNames' can only be specified when a column list is used and IDENTITY_INSERT is ON.</p>
  </blockquote>