title: SQL error: 'CREATE/ALTER PROCEDURE' must be the first statement in a query batch
body: <p>I am running a SQL script but getting an error:</p>
  
  <blockquote>
    <p>'CREATE/ALTER PROCEDURE' must be the first statement in a query
    batch</p>
  </blockquote>
  
  <p>Here's my code:</p>
  
  <pre><code>IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'myproc') AND type in (N'P', N'PC'))
  DROP PROCEDURE [dbo].[myproc]
  
  create PROCEDURE [dbo].[myproc]
  
  AS
  BEGIN
      select * from mytable
  END
  GO
  </code></pre>
  
  <p>How can I solve it?</p>