title: How to check if a stored procedure exists in sql server
body: <p>Please help I want to check if a stored procedure exists in my database. If it does exist, then that stored procedure should be dropped, and if it does not exist then the stored procedure should be created.</p>
  
  <p>Please tell me query</p>
  
  <p>This is my attempt so far:</p>
  
  <pre><code>try {
  objData.Query = "if exists (select * from dbo.sysobjects 
  where id = object_id(N'[dbo].["+ ProcName+"]') 
  and OBJECTPROPERTY(id, N'IsProcedure') = 1) 
  drop procedure [dbo].[ "+ ProcName+"]" ; // 
  objData.Query = " Drop Proc " + ProcName;
  objData.Execute(); 
  } catch 
  {
  }
  </code></pre>