SQL Server Batch Separator GO

Hi Friends,

Here I am going to explain the SQL Server Batch Separator GO.

Batch: Batch is a group of one or more TSQL statements submitted to SQL server for the execution.

1- To separate batches we use batch  separator “GO”

for example :

use sales
 go
select * from xtsales2012

2- you can also use GO to define how much times you want to execute your batch.

Syntax: GO [count]

where count is a positive integer.

for example :

print 'sqlservergeeks'
GO 5

1_SQL_Server_SQL Server_Batch_Separator_GO

3- GO is a utility command. So utilities never send GO to sql server.

4- playing with GO, means you can change this Batch Separator ‘GO’ with another option like ‘OK’

OPEN SSMS -> TOOLS -> Options

2_SQL_Server_SQL Server_Batch_Separator_GO

Now a popup window open here click on Query Execution in left side of this window.

3_SQL_Server_SQL Server_Batch_Separator_GO

here you can chage the text for batch separator. in my case i just type ok.

Now just restart the ssms to use the new batch separator

now we can use it as

use sales
ok
select * from xtsales2012

NOTE : Changeing batch separator is not a good idea. here we changed batch separator in SSMS only, this can not change GO as batch separator in sqlcmd utility. suppose if        you run some TSQL script on your server,created by another person on another server using batch separator GO, then it will give errors on your server.

 

Regards

Prince Rastogi

Like us on FaceBook Follow us on Twitter | Join the fastest growing SQL Server group on FaceBook

Follow me on TwitterFollow me on FaceBook

Avatar

About Prince Rastogi

Prince Rastogi is working as Database Administrator at Elephant Insurance, Richmond. He is having more than 8 years of experience and worked in ERP Domain, Wealth Management Domain. Currently he is working in Insurance domain. In the starting of his career he was working on SQL Server, Internet Information Server and Visual Source Safe. He is post graduate in Computer Science. Prince is ITIL certified professional. Prince likes to explore technical things for Database World and Writing Blogs. He is Technical Editor and Blogger at SQLServerGeeks.com. He is a regular speaker at DataPlatformDay events in Delhi NCR. He has also presented some in depth sessions about SQL Server in SQL Server Conferences in Bangalore.

View all posts by Prince Rastogi →

One Comment on “SQL Server Batch Separator GO”

  1. Hi,

    Explain with snapshot and step by step how to calculate an Query Execution Time in Sql Server 2008.

    Thanks in advance

Leave a Reply

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