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 |
|
gmerideth
Starting Member
10 Posts |
Posted - 2004-02-18 : 23:17:03
|
| Is it possible, from within a sql stored procedure to take the output from the procedure and call another sql stored procedure using the output from the first query to build a master output of data combining both answer sets?I have a table of companydata and activetickets. The query to get the company data returns back an answer-set of active companys (searched by a bit field isActive). This result set gets stored into an array using asp.net/iis. I then call the getactivetickets procedure using the values from the array which performs a COUNT(*) against the table using the company name as the query.Is there a way to get the getcompanydata proc to also call the getactivetickets proc on each company item that it finds? |
|
|
sachinsamuel
Constraint Violating Yak Guru
383 Posts |
Posted - 2004-02-19 : 01:26:49
|
| Hi,I guess u can do this using group by clause. And if it doesn't works than u can always go for a table datatype inspite of populating in array and giving roundtrips.Sachin |
 |
|
|
gmerideth
Starting Member
10 Posts |
Posted - 2004-02-19 : 12:00:46
|
| I tried looking into the group by clause and I can't see how the group by can call a procedure where it takes a parameter thats going to come from the initial lookup kind of like:select companycode from companygroup by ( gettickets companycode(1..array) )so what is the table datatype method? I'm looking through my t-sql and can't find that part but i'm still looking. |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2004-02-19 : 12:22:22
|
| Yes, you can store the results of a stored procedure to a temp table and then do some further processing. You can also write a udf that returns a table and use it in another sp. |
 |
|
|
gmerideth
Starting Member
10 Posts |
Posted - 2004-02-19 : 12:32:11
|
I did a little more digging and found using two inner joins I was able to get the dataset I was looking for in one procedure call using the group by clause. That just saved some 50 lines of asp.net code all into one nice procedure.I think I have to look at inner joins a great deal more than I did What is a udf by the way? |
 |
|
|
ValterBorges
Master Smack Fu Yak Hacker
1429 Posts |
Posted - 2004-02-19 : 13:09:15
|
| User Defined Function.To keep it short it's almost like a stored procedure but you can use it in place of a table if it returns a dataset.You can use it in a row to make calculations. |
 |
|
|
|
|
|