Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
sanjay5219
Posting Yak Master
240 Posts |
Posted - 2012-07-05 : 07:18:50
|
Hi All,I have to execute one procedure multiple time with diffrent paramater. First i have to check how many employees are their in emp table and then i have execute this procedure "Exec Build_EMp emp_id" in loop please suggest |
|
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts |
Posted - 2012-07-05 : 07:32:43
|
Here is an example of how you can execute a stored procedure in a while loop.DECLARE @counter INTSET @counter = 0;WHILE (@counter < 10)BEGIN EXEC dbo.YourStoreProc; SET @counter = @counter + 1;END If you have the ability to view or modify the stored procedure, there may be opportunities to avoid the while loop altogether. In general, except in a few special circumstances, experts discourage the use of while loops in T-SQL. |
|
|
|
|
|