SQL Server: Using EXCEPT find Mismatch rows from two tables

In this post, I am showing very command and important solution to find all mismatch rows from two tables of SQL Server.

Many times, I have found that my coworker are finding mismatch rows using NOT IN and EXISTS operators which are not advisable to execute over the big size of the table.

Please do not use NOT IN and EXISTS operators for finding mismatch rows from different tables. I am sharing quick note on this.

SQL Server has one very good Set Operators which is EXCEPT.
The EXCEPT returns distinct rows from the left table that are not output from the right table.

Below is a small demonstration:

First create two test table, one is Source and second is Destination:

Insert sample data into both table with some different values:

You can find that Name with “Alia” is not available in the Destination Table.

Find mismatch rows using EXCEPT:

Anvesh Patel

Leave a Reply

Be the First to Comment!

Notify of