title: There is already an object named '#xxxx' in the database
body: <p>I'm dropping/creating a temp table many times in a single script</p>
  
  <pre><code>IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
  DROP TABLE #uDims
  
  select * into #uDims from table1
  
  .... do something else 
  
  IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
  DROP TABLE #uDims
  
  select * into #uDims from table2 -- &gt;&gt; I get error here
  
  .... do something else 
  
  IF OBJECT_ID('tempdb..#uDims') IS NOT NULL
  DROP TABLE #uDims
  
  select * into #uDims from table3  -- &gt;&gt; and here
  
  .... do something else 
  </code></pre>
  
  <p>when trying to run the script, I get </p>
  
  <pre><code>There is already an object named '#uDims' in the database.
  </code></pre>
  
  <p>on the second and third "select into..."</p>
  
  <p>That is obviously a compile time error. If I run the script section by section, every thing will work well.</p>
  
  <p>There are many workaround for this issue, but I want to know why SSMS is upset on that.</p>