GO – SQL Server

While working on SQL Server we all encounter GO statement quite often. Till today GO statement for me was just an indication sent out to SQL Server utilities about end of a batch of Transact – SQL.

Today while going through MSDN I found a new (surprising) thing about GO. Go can actually take an integer argument. Yes! it is true. Go takes an optional integer argument. Something like this,

GO [count]

As per MSDN,

count is a positive integer. The batch preceding GO will execute the specified number of times.

What this means is, suppose you have a script like the one below,

INSERT INTO TestGO VALUES (10, 'testing go')
GO 5000

Here, INSERT statement will be executed 5000 times and you will end up inserting 5000 records in table.

~eNjOy LiFe~
Currently Listening to: In the summer time – SHAGGY

Advertisements

2 comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s