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 |
|
esthera
Master Smack Fu Yak Hacker
1410 Posts |
Posted - 2009-01-18 : 04:18:32
|
| How can I within a stored procedure loop though items and then execute another stored procedurefor example I want to select amount from useramounts where amount>@amount (variable in sp)then loop through this select @ do exec calculategain @id=useramountidplease advise |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-01-18 : 04:33:25
|
1) Use a cursor2) Use a WHILE loop E 12°55'05.63"N 56°04'39.26" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-01-18 : 08:56:25
|
quote: Originally posted by esthera How can I within a stored procedure loop though items and then execute another stored procedurefor example I want to select amount from useramounts where amount>@amount (variable in sp)then loop through this select @ do exec calculategain @id=useramountidplease advise
isnt it better to make this a udf so that you can avoid loop and simply call it from select. something likeselect amount,dbo.calculategain(useramountid) from useramounts where amount>@amount |
 |
|
|
|
|
|