What is the use of GO in SQL Server Management Studio & Transact SQL? What is the use of GO in SQL Server Management Studio & Transact SQL? sql-server sql-server

What is the use of GO in SQL Server Management Studio & Transact SQL?


It is a batch terminator, you can however change it to whatever you want alt text


Since Management Studio 2005 it seems that you can use GO with an int parameter, like:

INSERT INTO mytable DEFAULT VALUESGO 10

The above will insert 10 rows into mytable. Generally speaking, GO will execute the related sql commands n times.


The GO command isn't a Transact-SQL statement, but a special command recognized by several MS utilities including SQL Server Management Studio code editor.

The GO command is used to group SQL commands into batches which are sent to the server together. The commands included in the batch, that is, the set of commands since the last GO command or the start of the session, must be logically consistent. For example, you can't define a variable in one batch and then use it in another since the scope of the variable is limited to the batch in which it's defined.

For more information, see http://msdn.microsoft.com/en-us/library/ms188037.aspx.