GO is a batch breaker. It indicates where the querying tool must break up batches to send to SQL Server. It is not a T-SQL command
DECLARE @i int
Set @i = 0
Select * from SomeTable
SELECT @ i -- will work
DECLARE @i int
Set @i = 0
Select * from SomeTable
GO
SELECT @ i -- will not work. Error must declare variable @i. It was declared in the previous batch, not the current one
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability