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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2003-09-22 : 07:32:37
|
| Venedict writes "Dear Sir/Madam,Is it possible to write a recursive loops within the Stored Procedure?If so, how should i write the Store Procedure?Thanks.Regards,Venedict" |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2003-09-22 : 07:57:44
|
| Yes, you can easily use WHILE (condition) BEGIN ... END to loop within a stored procedure.FYI --"recursive" = a stored procedure calling itself, no loops involved."iterative" = loops within a stored procedure that does NOT call itself.- Jeff |
 |
|
|
Stoad
Freaky Yak Linguist
1983 Posts |
Posted - 2003-09-22 : 08:08:21
|
| create procedure spLoop @i intasif @i<32beginprint 'This is step #' + cast(@i as varchar(8))set @i=@i+1exec spLoop @iendreturnGOexec spLoop @i=7 |
 |
|
|
|
|
|