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 by: whitneyw
Posted on: 12/11/2007 at 11:52 PM
Tags:
Categories: Blog
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed
Comments are closed