SQLTeam.com | Weblogs | Forums

Checking differences

Hello

Is there a quick and neat way to check the delta between two tables?

I.e. which records are different or excluded or included in the compared table?

I often want to compare the results of two queries and I resolve in Power BI to create a simple data model.

Thanks!

You can use EXCEPT - for example:

SELECT col1, col2, col3 FROM table1
EXCEPT
SELECT col1, col2, col3 FROM table2

This will return the rows from table1 that are different - swap the order to get the rows from table2 that are different.

If the row exists in table1 - but doesn't exist in table2 it will be returned (included). Swap the order - and you get the included in table2.

1 Like

please post sample from each. or at least their schemas. it has been a while but in the past I have used BINARY_CHECKSUM to check data wise differences: which records are different

it has it's issues but might help.

1 Like