Comparing Data in TABLES

G

Gerrym

I have two Tables, A and B. Both have the same
structures, keys etc. Both are downloads from another
Table at different times. I would like to be able to
compare the data in these two tables to highlight the
different records. I need to compare the complete record
not just one field. Can anyone advise how to do this,
please.

Gerry
 
M

Madhivanan

Try this

Select T1.Field1,T1.Field2..T1.FieldN from Table1 T1, Table2 T2
where T1.Field1=T2.Field1 and T1.Field2=T2.Field2 and .... and
T1.FieldN=T2.FieldN

Madhivanan
 
D

Douglas J. Steele

Of course, that won't highlight the differences as Gerry asked for: it'll
only show the rows that are the same.
 
D

Douglas J. Steele

You can join them on their keys, and compare the non-key fields.

Something like:

SELECT T1.ID, T1.F1, T1.F2, T1.F3, T1.F4,
T2.F1, T2.F2, T2.F3, T2.F4
FROM T1 INNER JOIN T2
ON T1.ID = T2.ID
WHERE T1.F1 <> T2.F1
OR T1.F2 <> T2.F2
OR T1.F3 <> T2.F3
OR T1.F4 <> T2.F4
 
Top