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 |
|
esloat
Starting Member
8 Posts |
Posted - 2010-04-02 : 12:15:53
|
| I have a stored procedure with one input parameter. I want to execute this SP and then use the result set (table) as a subquery in a select statement. The result set from the SP does not need to be a permenant tableI found that I cannot use an EXEC cmd within a select statement (i.e. subquery or derived table) and am confused as to how to make the result set from the executed SP available to anothet select statement. the simplified example is: (1) I have a table of student ID's and names [Student_Table](2) I have a parameratized SP that returns a subset of student ID's and teacher names [SP_Teacher_Names](3) I want to select the student records from the [Student_Table] based on a join from the result set returned after executing the SP [SP_Teacher_Names]I think this is how to set up the SP to create a temporary table, but I haven't been able to make it work.Any thoughts would be greatly appreciated. Much thanks.Ed Sloat |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-04-02 : 12:41:04
|
| if you want to use sp result to join to table why not make it a table valued udf? so that it can be used just like table in join.------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
esloat
Starting Member
8 Posts |
Posted - 2010-04-07 : 13:01:11
|
| Thanks for these suggestions. I will try them out. Also, thanks for the referal to the SP examples. This has helped me a great deal to further understand the different ways to call and use SP and temporary tables. Thanks all.Ed Sloat |
 |
|
|
|
|
|