title: Why would IF EXISTS not work?
body: <p>I have a lot of code I am trying to run where I'm querying the sysobjects table to check if an object exists before I drop it and create it again.</p>
  
  <p>Issue being, sometimes if I go:</p>
  
  <pre><code>if not exists (select name from sysobjects o where o.name = 'my_table' and o.type =  'U') 
  CREATE TABLE my_table (..)
  go
  </code></pre>
  
  <p>it works, no worries. However, when I came back to run it again, I get this lovely error: </p>
  
  <pre><code>SQL Server Error on (myserver) Error:2714 at Line:10 Message:There is already an object named 'my_table' in the database.
  </code></pre>
  
  <p>Thanks for that, SQL Programmer. I actually asked for you not to create this table if it already exists. -_-</p>
  
  <p>Any ideas?</p>