Twitter

Follow SQLQuill on Twitter

Subscribe

MN Pass

TSQL Tip O’ the Week – 8/23/11 – Repeatable GO

This weeks tip:

I just found this one out the other day – GO has a repeat option!  You can execute a batch multiple times by adding a count after go.

Here’s an example:

Select Getdate()
GO 5

Here are the results….

Fullscreen capture 8222011 101444 PM.bmp

This may not seem like much, but for creating sets of test data or random data, this is very useful.

Here are some related posts from the intraweb:

Note when I was reading up on this, I remember Rob Farley (Blog/Twitter) mentioning a trick about this in his talk – The Incredible Shrinking Execution Plan at PASS 2010.

His trick, which I’ve tried, is to change the batch separator in a co-workers SSMS to “Select”, as shown below – it doesn’t take effect until the next connection and it will drive them crazy:

Options

Note for this tip, they will still get the same error:

Error

Kudos Rob.

Previous Tips O’ the Week

Leave a Reply

  

  

  

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>