title: SQL Server 2012 temp table OBJECT_ID issue
body: <p>We have an issue upgrading to SQL Server 2012. I am using the following script to create temporary tables that used to work fine on SQL Server 2008 R2 but now it is generating an error with 2012:</p>
  
  <pre><code>if (OBJECT_ID( 'tempdb..#idstable') &gt; 0)
      truncate table #idstable
  else
      create table #idstable (id int not null)
  </code></pre>
  
  <p>the error thrown is </p>
  
  <blockquote>
    <p>There is already an object named '#idstable' in the database.</p>
  </blockquote>
  
  <p>This is obviously not thrown the first time I use the script (in the same transaction).</p>
  
  <p>Any idea? Thank you!</p>