I want to join the output of a stored procedure with a table. I know and i am sure that it is possible because i did it before but, i can't remember how. Could anyone help me with that, please?
Asked
Active
Viewed 8,933 times
0
-
1Please retag your question to show your database. – GSerg Jun 11 '11 at 19:29
-
If you used a UDF instead this would be easy. With SP im not sure if it works. – Magnus Jun 11 '11 at 19:32
-
You might want to check out http://www.kodyaz.com/articles/how-to-sql-select-from-stored-procedure-using-openquery-openrowset.aspx – Magnus Jun 11 '11 at 19:38
-
1You might want to have a look at this question: [How to SELECT * INTO temp table FROM Stored Procedure](http://stackoverflow.com/questions/653714/how-to-select-into-temp-table-from-stored-procedure) – Andriy M Jun 11 '11 at 19:40
1 Answers
5
You would have to insert the results of your stored procedure into a temporary table and then join to that.
e.g. insert into #temp_table exec sp_mySP
You would have to define the temporary table structure to match the output of your stored procedure though.

Duncan Howe
- 2,965
- 19
- 18
-
thank you :) my problem was that i forgot renaming the table returned from the stored procedure when joining between it and the main one – Soha Nasr Jun 11 '11 at 23:23