Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding unmatched rows between two tables 1

Status
Not open for further replies.

btt423

Programmer
Jan 28, 2002
31
US
I have two tables (POSITION, CONTACT_INFO) that have, among other items, SSN and Org_Code. I need a query to find which rows in the contact_info table do not have a matching ssn and org code in the position table.

I know in Oracle, there is a MINUS operator which can do this. Is there an equivalent in SQL Server??

Thanks for your help,
Brinson
 
Something like this should give you what you need:

Assuming you are using ssn as your primary key.

select ci.ssn as ci_ssn, ci.org_code as ci_orgcode
p.ssn as p_ssn, p.org_code
from Contact_Info ci left outer join Position p
on ci.ssn = p.ssn
where p.ssn is null

Hope this helps.
DrewConn
 
Worked like a charm... thanks so much for your help!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top