SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

GO More than Once?

SSC had a fairly routine article up recently about The GO Command the Semi Colon Terminator which I read, and when I followed along on the associated discussion came across an interesting comment that noted in SSMS you can add an integer param to GO to have it execute the batch multiple times. To see in action, try this:
select newid()
go 5
Not sure what I'll use it for yet, of if ever, but don't know that I would have learned about it any other way than just my daily keep up with the tech world reading.


I'm Andy Warren, currently a SQL Server trainer with End to End Training. Over the past few years I've been a developer, DBA, and IT Director. I was one of the original founders of SQLServerCentral.com and helped grow that community from zero to about 300k members before deciding to move on to other ventures.


Posted by SREERAJ. R on 24 January 2010

The given SELECT statement will be executed 5 times when a GO 5 is mentioned.

Posted by SREERAJ. R on 24 January 2010

I think it would be useful to insert large chunk of dummy data to tables.

Posted by jcrawf02 on 25 January 2010

I've used it to play with queries, when I want an average runtime (STATISTICS TIME or IO, etc). GO 10, then avg the results.

Leave a Comment

Please register or log in to leave a comment.