GO is not a Transact-SQL statement; it is often used in T-SQL code. Go causes all statements from the beginning of the script or the last GO statement (whichever is closer) to be compiled into one execution plan and sent to the server independent of any other batches. SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO.
The GO Statement must be written in new line as it is not a T-SQL command. T-SQL statement cannot occupy the same line as GO. GO statement can contain comments.
Following is example for SQL SERVER for database Adventureworks.
USE AdventureWorks2014; GO DECLARE @MyMsg VARCHAR(50) SELECT @MyMsg = 'Hello, World.' GO ---- @MyMsg is not valid after this GO ends the batch.
—- Yields an error because @MyMsg not declared in this batch.
PRINT @MyMsg GO
Here is question to you – did you know about this feature before you read it here?
Reference: Pinal Dave (https://blog.sqlauthority.com)