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
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'
EXEC 'StoredProcedureName'
GO 100
Labels: SQL
2 Comments:
Hey Sankar,
Howdy? Nice to 'stumble' upon your (thanks to Gom's blog)!
Send me your contact email..
-Raga
This is really helpful.
Thanks
Sumana
Post a Comment
<< Home