Tuesday, September 25, 2012


Recently at an  SQLSaturday ,I learnt a trick - using GO to execute a statement or block of statements in a loop.

GO is a batch separator and it is not a T-SQL command.A long time back, I used to change the batch separator option to my name instead of GO and have a unwary developer look at SQL Server execute a piece of code with my name on it and GO crazy .

Since SQL Server 2005,the GO syntax has been changed to GO [count], where count is an integer.
Specifying a value for [count] would cause the block of code preceding the GO to be executed [count] times.

For example lets say we have a block of code

/*Start SQL Block*/
/*End SQL Block*/
GO 10

This will cause all the statements in this block to execute 10

This is the code from Books online that is used to generate a random number 4 times

DECLARE @counter smallint;
SET @counter = 1;
WHILE @counter < 5
      SELECT RAND() Random_Number
      SET @counter = @counter + 1

This can be replaced by

SELECT RAND() Random_Number
GO 4

Generally, while tuning a query, I would execute a block of statements or a  stored procedure multiple number of times to get a distribution of the execution times each time after clearing the cache and repeat this under varying test conditions.Whenever there is a necessity to execute statements in a loop, GO [count] syntax would come handy without having to code additional logic.

Friday, September 21, 2012

SQLSaturday in Pittsburgh

I am double minded about going to this one....Its going to be a 4.5 hour drive

Welcome to SQLSaturday #171

SQLSaturday is a full day training event for SQL Server professionals and those wanting to learn about SQL Server. This event will be held Oct 6, 2012 at La Roche College, Zappala Center, 9000 Babcock Boulevard, Pittsburgh , PA 15237. Admittance to this event is free, but we do charge a lunch fee of  $10.00 so that we can provide a cafeteria lunch - not pizza!   This donation helps to defer the cost of lunch and morning coffee, juice and water. 

Tuesday, September 18, 2012

24 Hours of PASS

24 Back-to-back Hours of Free SQL Server Training!

Get your learning on - indulge in free online SQL Server training with the upcoming 24 Hours of PASS Summit Preview event on September 20, 2012. Join SQL Server experts as they take to the virtual stage with in-depth sessions on the hottest SQL Server topics over 24 consecutive (and free!) technical webcasts. No matter where you are in the world, you’ll gain access to best SQL Server training, delivered to your computer.

Browse the sessions by schedule or track and register today, it's free.
This 24 Hours of PASS event gives you a glimpse at the unmatched technical content PASS Summit 2012 has to offer across 190+ technical sessions, pre-conference seminars, and invaluable networking opportunities. Find out why you should attend and justify your attendance today. You won’t want to miss PASS Summit 2012 in Seattle, WA, Nov. 6-9.

Thursday, September 6, 2012

Powershell 3.0 is available

Powershell 3.0 is available for download.Yeah!.It reqires .net framework 4.0 as a prerequisite.You can down load it here.