title: SQL Server: What are batching statements (i.e. using "GO") good for?
body: <p>I know that in SQL Server <code>GO</code> <a href="https://stackoverflow.com/questions/2299249/what-is-the-use-of-go-in-sql-server-management-studio">is considered a batch separator</a>.</p>
  
  <p>My question is: <strong>What is the point of having a batch separator?</strong> What benefit does it give you and why would you want to use it?</p>
  
  <p>Example: I've often seen it used in SQL code as follows and I can't see why it would be considered a best practice. As far as I can tell the code would the same without all the <code>GO</code> statements:</p>
  
  <pre><code>USE AdventureWorks2012;
  GO
  BEGIN TRANSACTION;
  GO
  IF @@TRANCOUNT = 0
  BEGIN
      SELECT FirstName, MiddleName 
      FROM Person.Person WHERE LastName = 'Adams';
      ROLLBACK TRANSACTION;
      PRINT N'Rolling back the transaction two times would cause an error.';
  END;
  ROLLBACK TRANSACTION;
  PRINT N'Rolled back the transaction.';
  GO
  </code></pre>
  
  <p>(source: <a href="http://technet.microsoft.com/en-us/library/ms187807.aspx" rel="noreferrer">technet documentation</a>):</p>