title: Identity_insert on in temporary table
body: <p>I'm having a problem running a stored procedure in SQL Server 2012 and 2008 R2 while it worked fine in my SQL Server 2000 and 2005.</p>
  
  <p>Please see code below:</p>
  
  <pre><code>SELECT * INTO #TB_Table_1
  FROM (SELECT TOP 1 * FROM TB_Table_2) A
  
  TRUNCATE TABLE #TB_Table_1
  </code></pre>
  
  <p>My existing sp has this code. The purpose is only to copy the structure of <code>TB_Table_2</code>. </p>
  
  <p>Note: <code>TB_Table_2</code> has an identity column <code>Master_ID</code>.</p>
  
  <p>Next, I will try to insert data with the following code. And this is where I'm having trouble.</p>
  
  <pre><code>INSERT INTO #TB_Table_1
  SELECT * FROM TB_Table_2
  WHERE ISNULL(Date,'') = ''
  AND ISNULL(ID,'') = ''
  </code></pre>
  
  <p>Is there something I need to set up in SQL Server to make this work?</p>
  
  <p>EDIT:</p>
  
  <p>the error that I am getting is </p>
  
  <blockquote>
    <p>An explicit value for the identity column in table
    '#TB_Table_1' can only be specified when a column list is
    used and IDENTITY_INSERT is ON.</p>
  </blockquote>