Hi,
Can anybody please help with a SQL query to compare 4 column values between 2 tables to check if any data changes have taken place for a unique row ID ?
Many thanks.
Hi,
Can anybody please help with a SQL query to compare 4 column values between 2 tables to check if any data changes have taken place for a unique row ID ?
Many thanks.
Assuming that NULLs are not relevant here, then:
SELECT t1.id, t1.col1, t2.col1, t1.col2, t2.col2, t1.col3, t2.col3, t1.col4, t2.col4
FROM dbo.table1 t1
INNER JOIN dbo.table2 t2 ON t2.id = t1.id AND
((t2.col1 <> t1.col1) OR (t2.col2 <> t1.col2) OR
(t2.col3 <> t1.col3) OR (t2.col4 <> t1.col4))