title: There is already an object named '#columntable' in the database
body: <p>I am trying the following query</p>
  
  <pre><code>   if exists (select 1  from emp where eid = 6)     
       begin
          if object_id('tempdb..#columntable') is not null 
            begin 
               drop table #columntable                         
            end                     
          create table #columntable (oldcolumns varchar(100))   
       end
    else
       begin
          if object_id('tempdb..#columntable') is not null 
            begin 
               drop table #columntable            
            end     
  
  
      create table #columntable (newcolumns varchar(100))   
   end
  </code></pre>
  
  <p>But I am getting the error </p>
  
  <pre><code>Msg 2714, Level 16, State 1, Line 8
  There is already an object named '#columntable' in the database.
  </code></pre>
  
  <p>Can anyone suggest why? The same query works fine if I do not write the else part.</p>