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 |
|
duleepnagahawatte
Starting Member
16 Posts |
Posted - 2008-01-03 : 04:10:39
|
| I want to select parameter values from a select statement and then pass those values to a stored procedure, so the 2nd stored procedure will execute per value.EX - 1st select statement will select 100 account numbers. and then they will pass to a 2nd stored procedure which will be executed per account number and produce results (say account details)So the 2nd procedure will be executed 100 times and will produce 100 lines on the result pain. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-01-03 : 04:36:11
|
| Try this:-DECLARE TABLE @Temp(AccntNo int)INSERT INTO @TempSELECT 1000 UNION ALLSELECT 1050....DECLARE @ID intSELECT @ID = MIN(AccntNo)FROM @TableWHILE @ID IS NOT NULLBEGINEXEC SPName @Param=@IDSELECT @ID=MIN(AccntNo)FROM @TableWHERE AccntNo>@IDEND |
 |
|
|
duleepnagahawatte
Starting Member
16 Posts |
Posted - 2008-01-03 : 04:44:30
|
| Only problem is that the accntNo is a "varchar", how can i get over that problem.thanks |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2008-01-03 : 04:54:34
|
quote: Originally posted by duleepnagahawatte Only problem is that the accntNo is a "varchar", how can i get over that problem.thanks
The above example would work for varchar datatype as wellMadhivananFailing to plan is Planning to fail |
 |
|
|
duleepnagahawatte
Starting Member
16 Posts |
Posted - 2008-01-03 : 07:19:11
|
| Thank you Both. it works like a dream |
 |
|
|
|
|
|