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 |
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2007-01-02 : 20:16:48
|
| hi,can somebody tell me how to call SP in another SP select statement..? i've seen ppl doing it something like this.. Select column1, coulumn2, (select EXEC SP_NAme), blablathanks in advance... :) |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-01-02 : 20:59:57
|
You can call one SP in other using EXEC like this:Create Proc p1asbegin Exec p2 param1, param2, ...end But I don't think you can nest EXEC within SELECT statement.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
maya_zakry
Constraint Violating Yak Guru
379 Posts |
Posted - 2007-01-02 : 23:04:05
|
| hi harsh,using that method, the datarecord will split in two tables, where as i need it to combine with existing select statement.. meaning i need to treat the sp as another new columns :-my result :-abc,10,F,nanny, <--- from my main selectabc,fri,78,pp,foo,33,bar <--- from another SPcombine, and get 1 row record :-abc,10,F,nanny,abc,fri,78,pp,foo,33,barNOTE: Not considering join method for some reason |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-02 : 23:06:14
|
quote: Originally posted by maya_zakry i've seen ppl doing it something like this.. Select column1, coulumn2, (select EXEC SP_NAme), blabla
I seriously doubt that...Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-02 : 23:07:16
|
quote: Originally posted by maya_zakry NOTE: Not considering join method for some reason
Why?If not, you must resort to UNION operator together with GROUP BY and a lot of aggregated MAXs.Peter LarssonHelsingborg, Sweden |
 |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2007-01-02 : 23:08:06
|
| Why not have a new SP that outputs the record you want?Peter LarssonHelsingborg, Sweden |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-01-03 : 09:32:53
|
| Create table #t1(id int identity(1,1),.....)Insert into #t1 EXEC proc1Create table #t2(id int identity(1,1),.....)Insert into #t2 EXEC proc2Now join the tables using idBut I want to know where you want to display these?MadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|