Sunday, April 15, 2007

Transact SQL - Executing Statements multiple times

In order to execute a set of SQL statements / stored procedure multiple times - I have been using the traditional method of WHILE loop. The other day Vijay suggested an easy approach making use of the GO command.

We can specify a number 'N' after GO command and the batch will be executed 'N' number of times. For example - if we want to call the stored procedure 'StoredProcedureName' 100 times - the command would be

EXEC 'StoredProcedureName'
GO 100

Labels:

2 Comments:

Blogger Raga said...

Hey Sankar,
Howdy? Nice to 'stumble' upon your (thanks to Gom's blog)!

Send me your contact email..

-Raga

10:13 AM  
Blogger Sumana said...

This is really helpful.
Thanks
Sumana

4:33 AM  

Post a Comment

Links to this post:

Create a Link

<< Home