At first I thought I would just add another sentence to my previous post, but then I realized that this feature is not even documented anywhere, and it might be useful to mention it in its very own post. I have no idea why it is undocumented, but it has been part of all command interfaces to TSQL that I have used for the last 20 years.
When you use GO as a batch terminator, you can follow it by an integer, which indicates that the batch should be executed N times.
I use this frequently when populating test tables. In my previous post, I ended with this suggestion:
-- You can add more rows by just rerunning the INSERT statement from above, as many times as you would like.
So, to run the INSERT 5 times, I would do this:
INSERT INTO details
(SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID,
UnitPrice, UnitPriceDiscount, rowguid, ModifiedDate)
SELECT SalesOrderID, SalesOrderDetailID, CarrierTrackingNumber, OrderQty, ProductID, SpecialOfferID,
UnitPrice, UnitPriceDiscount, rowguid, ModifiedDate
FROM Sales.SalesOrderDetail
GO 5
Have fun!
~Kalen