Solved

How do I combine the results of two stored procedures into one dataset?

Posted on 2010-08-25
5
463 Views
Last Modified: 2012-05-10
I have two stored procedures.  One (usp_Products) results in a distinct list of products my company sells.  The other (usp_DocType) results in a distnict list of document types we provide.  I want to combine these so that I get one dataset with both.  Example below.

Products                        DocumentTypes
A                                             1
B                                             2
C                                             3


0
Comment
Question by:NevSoFly
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 12

Accepted Solution

by:
mcv22 earned 500 total points
ID: 33525035
CREATE TABLE #Product
(
   ID INT IDENTITY(1,1),
   Product VARCHAR(MAX)
)

CREATE TABLE #DocumentType
(
   ID INT IDENTITY(1,1),
   DocumentType INT
)

INSERT #Product (Product) EXEC usp_Products
INSERT #DocumentType (DocumentType) EXEC usp_DocType

SELECT
 p.Product AS Products,
 d.DocumentType AS DocumentTypes
FROM
 #Product p
FULL JOIN
 #Document d
ON
 p.ID = d.ID
0
 
LVL 16

Expert Comment

by:Sheils
ID: 33525039
Can you provide the codes for the stored procedures
0
 
LVL 5

Expert Comment

by:jijeesh
ID: 33525150
If you just call both SP in an another single SP, the result will apprear in a single data set, but in difeerent DataTables.
0
 
LVL 8

Expert Comment

by:mustaccio
ID: 33525275
How do you know that the document type 1 corresponds to the product A etc.?

0
 

Author Closing Comment

by:NevSoFly
ID: 33527089
Thanks to all for your help.
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Cannot connect to SQL express 2008 R2 installed on Server 2016 5 51
SQL query 7 50
t-sql left join 2 36
Ordering displaying data in a drop down 3 15
If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question