• You must be very careful using the Batch Separator Sentence: GO

    If the previous batch failed, the result will be an error message, and the next batch will be executed. Example:

    USE TestDB

    GO

    DELETE FROM dbo.TableName_In_TestServer_AND_ProductionServer

    GO

    If you execute the previous query on Test Server Instance, it will be ok, but if you execute it on Production Server Instance it will be a serious pain to you: An error message will be shown because TestDB does not exists on Production Server on the first batch and the Delete Batch will be executed.

    A peculiarity is that GO cannot be on the same line of any query and throws an error message:

    DELETE FROM dbo.TableName_In_TestServer_AND_ProductionServer GO

    And you could not use a variable declared on a previous batch:

    DECLARE @Var VARCHAR(10)

    SET @Var = 'Hello'

    GO

    Print @Var

    GO