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 |
|
craigmacca
Posting Yak Master
142 Posts |
Posted - 2008-09-01 : 11:34:09
|
| Hi i need a stored proc that does the following1. select Distinct(ParentId) from table A2. then for each ParentId loop through and exec another stored proc (which i already have) passing the ParentId as the addin paramjust not sure what the best way to do this is? |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2008-09-01 : 11:36:00
|
[code]DECLARE @ID VARCHAR(100)SELECT @ID = MIN(ParentID)FROM TableAWHILE @ID IS NOT NULL BEGIN EXEC AnotherSP @ID SELECT @ID = MIN(ParentID) FROM TableA WHERE ParentID > @ID END[/code] E 12°55'05.63"N 56°04'39.26" |
 |
|
|
|
|
|