title: Creating a stored procedure if it does not already exist
body: <p>I want to check if a list of stored procedures exist.  I want this all to be done in 1 script, one by one.  So far I have this format:</p>
  
  <pre><code>USE [myDatabase]
  GO
  
  IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'sp_1')
  BEGIN
  CREATE PROCEDURE sp_1
  AS
  .................
  END
  GO
  
  IF NOT EXISTS (SELECT * FROM sys.objects WHERE type = 'P' AND name = 'sp_2')
  BEGIN
  CREATE PROCEDURE sp_2
  AS
  .................
  END
  GO
  </code></pre>
  
  <p>and so on.  However, I'm getting the following error: </p>
  
  <blockquote>
    <p>Incorrect syntax near the keyword 'Procedure'.</p>
  </blockquote>
  
  <p>Why isn't what I'm doing working correctly?</p>