Pages

Thursday, July 10, 2008

GO in SQL Server

Today, I was looking at couple of forums and my mailbox and encountered the question "What is GO"? in SQL Server? is it a command?

I was able to reply to this question in all the forums but its really important for me to put this in blog so that my blog readers can get the information.

It is basicaclly signals the end of a batch of Transact-SQL statements. Its not a T-SQL statement and its a command recognized by the osql and isql utilities and SQL Query Analyzer. 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.

USE pubs
GO
SELECT COUNT(*)
FROM authors
GO

This example creates two batches. The first batch contains only a USE pubs statement to set the database context and the next one is to retun the data.

1 comment:

Sandeep said...

good information.....