SQL to compare 2 records for differences
Posted on 2012-09-12
Shruks, my SQL must be very rusted.
I have 2 similar tables say with 3 columns (Code, columnA, columnB). Code is Primary Key and both table contains 10 records each. They are suppose to contain the same values for each record but are not.
How will a SQL be able to extract out the records that have differences in values. Below is the SQL I have in mind. But if i many columns, this is going to be very tedious. I am there are better alternative SQL than my below statement.
From Table1 a, Table b
Where a.Code = b.Code
And (a.ColumnA <> b.ColumnB Or a.ColumnB <> b.ColumnB)