Solved

return result from 2 tables

Posted on 2009-07-15
3
177 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
[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
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

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 …
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

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