Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Joining an SP
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Yak Posting Veteran

United Kingdom
68 Posts

Posted - 05/25/2013 :  07:09:55  Show Profile  Visit richardlaw's Homepage  Reply with Quote

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
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 05/25/2013 :  08:32:42  Show Profile  Reply with Quote
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

Yak Posting Veteran

United Kingdom
68 Posts

Posted - 05/25/2013 :  09:13:59  Show Profile  Visit richardlaw's Homepage  Reply with Quote
OK thanks, I'll give that a try.
Go to Top of Page

Very Important crosS Applying yaK Herder

52326 Posts

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

SQL Server MVP
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000