title: Why does the CREATE PROCEDURE statement fail when I use it with IF Statement here?
body: <p>I am trying to DROP a stored procedure if it exists and then CREATE it by doing this way:</p>
  
  <pre><code>IF OBJECT_ID('[dbo].[myStoredProc]') IS not NULL
      DROP PROCEDURE dbo.myStoredProc
  
  
  CREATE PROCEDURE [dbo].[myStoredProc]
  (
      @parameter1 BIT
  ) AS
  
  IF @parameter1 = 1
      BEGIN
               ....
  </code></pre>
  
  <p>But it complains that :</p>
  
  <blockquote>
    <p>"CREATE PROCEDURE must be the only statement in the batch"</p>
  </blockquote>
  
  <p><strong>Question:</strong> How can I fix my script to overcome this?</p>