title: How can I avoid a timestamp insert error when copying data from one table to another?
body: <p>I'm trying to cull the data in a list of tables (~30) based on a primary key.</p>
  
  <p>My approach has been to:
  1.Create an intermediate table &amp; load it with the desired data for each table <br/>
  2.Truncate the original table<br/>
  3.Insert the data from the intermediate table back into the original table.<br/></p>
  
  <p>Here's the code I'm using thus far:</p>
  
  <pre><code>declare @table nvarchar(max) 
  open tab
  fetch next from tab into @table
  while(@@FETCH_STATUS = 0)
         begin
                print @table
               exec ('select * into ' +@table+'_intermediate from '+@table+' where P_ID in( select P_ID from pc_table )')
               exec ('truncate table '+@table)
               exec ('insert into '+@table+' select * from '+@table+'_intermediate')
               exec ('drop table '+@table+'_intermediate') 
              fetch next from tab into @table
         end
  close tab
  deallocate tab
  </code></pre>
  
  <p>I'm running into an error:</p>
  
  <pre><code>Cannot insert an explicit value into a timestamp column. 
  Use INSERT with a column list to exclude the timestamp column, 
  or insert a DEFAULT into the timestamp column.
  </code></pre>
  
  <p>So, that error is telling me that I can't insert anything into a timestamp column.</p>
  
  <p>In order to avoid selecting the timestamp, I need to avoid selecting it (i.e. using select *).  </p>
  
  <p>Is there a simple way of selecting all columns except of type timestamp, or will I need to go into the information schema and build a dynamic select statement for each table? </p>
  
  <p>(or the implicit question, is there a better way of doing what I'm trying to do?)</p>
  
  <p>Thanks</p>