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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joining an SP

Author  Topic 

richardlaw
Yak Posting Veteran

68 Posts

Posted - 2013-05-25 : 07:09:55
Hi

I've created a SP (SP1) which returns a single row of data based on one input variable.

I'd now like to create another SP (SP2) which joins SP1. In other words, I have a table which lists the same variable used with SP1, and I'd like to join - like a loop against the possible variables listed in another table.

Is this possible?

Thanks as always

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-05-25 : 08:32:42
You can do something like that, for example, using OPENQUERY. But those are really hacks, and there is no straightforward way to join one stored procedure to another similar to what you might do with tables/views.

The best approach would be to write a new stored proc that joins the queries in the code within the stored proc.
Go to Top of Page

richardlaw
Yak Posting Veteran

68 Posts

Posted - 2013-05-25 : 09:13:59
OK thanks, I'll give that a try.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-05-25 : 09:20:30
If it was a table valued user defined function instead of stored procedure you could have simply joined to it.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -