title: TSQL - How to use GO inside of a BEGIN .. END block?
body: <p>I am generating a script for automatically migrating changes from multiple development databases to staging/production.  Basically, it takes a bunch of change-scripts, and merges them into a single script, wrapping each script in a <code>IF whatever BEGIN ... END</code> statement.</p>
  
  <p>However, some of the scripts require a <code>GO</code> statement so that, for instance, the SQL parser knows about a new column after it's created.</p>
  
  <pre><code>ALTER TABLE dbo.EMPLOYEE 
  ADD COLUMN EMP_IS_ADMIN BIT NOT NULL
  GO -- Necessary, or next line will generate "Unknown column:  EMP_IS_ADMIN"
  UPDATE dbo.EMPLOYEE SET EMP_IS_ADMIN = whatever
  </code></pre>
  
  <p>However, once I wrap that in an <code>IF</code> block:</p>
  
  <pre><code>IF whatever
  BEGIN
      ALTER TABLE dbo.EMPLOYEE ADD COLUMN EMP_IS_ADMIN BIT NOT NULL
      GO
      UPDATE dbo.EMPLOYEE SET EMP_IS_ADMIN = whatever
  END
  </code></pre>
  
  <p>It fails because I am sending a <code>BEGIN</code> with no matching <code>END</code>.  However, if I remove the <code>GO</code> it complains again about an unknown column.</p>
  
  <p><strong>Is there any way to create and update the same column within a single <code>IF</code> block?</strong></p>