Solved

return result from 2 tables

Posted on 2009-07-15
3
170 Views
Last Modified: 2012-05-07
I want to return 2 columns from stored procedure:  FullName and UserSSN.
I have got 2 tables that contain different types of users.
Both tables have got the columns: FullName, UserName and PayerId.
The parameter I send in is @PayerId.
I want to return from both tables FullName and UserSSN.
How would i do that?
0
Comment
Question by:johnkainn
3 Comments
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 100 total points
ID: 24860392
SELECT FullName, UserSSN
FROM Table1
WHERE PayerID = @PayerID
UNION
SELECT FullName, UserSSN
FROM Table2
WHERE PayerID = @PayerID
0
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 100 total points
ID: 24860403
select fullname, userssn
from table1
where payerid =  @payerid
union all
select fullname, userssn
from table2
where payerid =  @payerid
0
 
LVL 17

Assisted Solution

by:pssandhu
pssandhu earned 50 total points
ID: 24860426
CREATE PROCDURE sp_GetPayerInfo ( @PayeriD INT)
AS
BEGIN

Select a.FullName TableOneName, a.UserSSN as TableOneSSN, b.FullName TableTwoName, b.UserSSN as TableTwoSSN
From TableA a inner join TableB b
           ON a.PayerID = b.PayerID
Where  a.PayerID = @payerid
END
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

707 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now