Sunday, April 4, 2010

GO n

Never knew this!
If you place a number (n) following the GO statement, Management Studio loops, running the preceding SQL statement n times. e.g....

CREATE TABLE dummy (ID INTEGER IDENTITY(1,1), data UNIQUEIDENTIFIER)
GO

INSERT INTO dummy (data) VALUES (NEWID())
GO 500

SELECT ID, data FROM dummy

No comments: