title: Different ways to check if a stored procedure exists in SQL Server
body: <p>I found two ways to check if a stored procedure exists in our current code:</p>
  
  <pre><code>if object_id('dbo.procedure_to_drop') is not null
  </code></pre>
  
  <p>vs</p>
  
  <pre><code>if exists (select * from sysobjects where id = object_id('dbo.procedure_to_drop') and sysstat &amp; 0xf = 4)
  </code></pre>
  
  <p>What's the difference between them and which one is the prefer way?</p>