GO, Go, go


that’s how we tell SQL Server to  execute query or batch of tsql statements.

However GO is not TSQL statement. it’s just command recognized by SQL server utilities like SSMS, SQLCMD, OSQL that signals it is end of batch and it is time to execute the code.

If you want to execute your batch few times for example when you populate table you can  use GO and integer to execute batch that many times.

GO 5



As you can see in picture above it executes everything in the batch, including variable declaration. That’s why we got NULL as result 5 times.

You shouldn’t include GO when executing commands using ODBC or OLE DB drivers because you will get an error during code execution.




MS documentation says to not do that as in result you’re going see  error:

Incorrect syntax near 'GO'

Reason for that is that SQL Server parser doesn’t recognize GO as this is not part of the TSQL syntax.


Author: G L

Greg's a Senior Database Administrator in Austria with over 15 years of experience in IT (servicedesk/helpdesk, software engineer, database administrator) Likes SQL Server administration, powershell and testing new features

Leave a Reply

Your email address will not be published. Required fields are marked *