The Power of GO:The insights of an SQL geek


The insights of an SQL geek: The Power of GO

Monday, January 5, 2009

The Power of GO

Hello all.

Nice little tip for you all.
If you don't want to use complicated loops, declare counters and so on you can use to power of the GO keyword to the rescue.
The GO keyword in SQL 2000, 2005 tells the Server to execute the preceding code as one batch
Use the GO in 2005 to actually tell the server how many times you would like the batch to execute.

For an example we will create a new table and insert new data 1000 times

CREATE TABLE
dbo.TempTable
(ID INT IDENTITY (1,1),
ROWID uniqueidentifier)
GO
INSERT INTO dbo. TempTable (ROWID)
VALUES (NEWID())
GO 1000


Enjoy and don’t forget to leave some comments
Itay

No comments:

Post a Comment