Click here to Skip to main content
15,885,835 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Compare 2 tables and get the Unmatched rows? But In each table there are more than 500000 records.I want to compare 2 tables by using LastName,FirstName,MiddleName,SSN Number,Nap_Id number, and DateOfBirth ?
Posted

1 solution

To fetch records which are in table1 but not in table2
SQL
select LastName,FirstName,MiddleName,SSN Number,Nap_Id number
From table1
EXCEPT
select LastName,FirstName,MiddleName,SSN Number,Nap_Id number
From table2

To fetch records which are in table2 but not in table1
SQL
select LastName,FirstName,MiddleName,SSN Number,Nap_Id number
From table2
EXCEPT
select LastName,FirstName,MiddleName,SSN Number,Nap_Id number
From table1

Happy Coding! :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900