Welcome to

Magenic Technologies Community Blog

Sign in | Join | Help

The W Blog

Whitney Weaver, Magenic Technologies
Just GO already

A quick one today...I have been meaning to post this for a couple days but keep getting distracted. 

Do you know how to turn a simple query statement into a lean mean looping machine without while loops or cursors?  Okay, so maybe I've had too much coffee for one evening but I find this handy.  :)

Here's the simple syntax:

SELECT 'Woo hoo' AS myBrilliantOutput;
GO 5

This will give you 5 result sets in Management Studio.  Under the covers SQL Server is handling this as 5 separate requests.  It's not functionality that you're going to write into your application but for some quick and dirty load testing it can be super useful.  I also use this to insert sample data into a table for index testing.

So there's a couple good options available through pretty simple syntax.  If you use this for something other than the items listed drop a geek a line.  I'm always interested in seeing how other people do things.

Posted: Tuesday, December 11, 2007 2:14 AM by WhitneyW

Comments

Mack Bell said:

Brilliant!  Sheer genius.  Thanks Mr. W.  I've always used 'GO' for batch termination, never realizing it's other potential.  Very nice indeed.

M

# December 14, 2007 4:06 PM
Anonymous comments are disabled