SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

richardlaw
Yak Posting Veteran

United Kingdom
68 Posts

Posted - 05/25/2013 :  07:09:55  Show Profile  Visit richardlaw's Homepage  Reply with Quote
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
Flowing Fount of Yak Knowledge

3568 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

richardlaw
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

visakh16
Very Important crosS Applying yaK Herder

India
52309 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
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000