Query that compares two tables

hainejo

Board Regular
Joined
Jun 27, 2002
Messages
57
I have a two tables that I would like to compare to identify changes. I import data ecery morning into a table. I would like to compare todays data with yesterdays data and identify what records changed. Both tables are identical in design. Can anyone provide the SQL statement(s) to accomplish this?
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
If you use the Unmatched Query Wizard it will create a query for you that will show the records that have changed.


HTH

Peter
 
Upvote 0
Peter, your suggestion works great if there is one record that is not in the other. However, what if you want to compare both record for record and field for field in table?

Foxhound
 
Upvote 0
I was forgetting that the Wizard only works with one field :oops:
If you go into design view after using the wizard you will see that it has created a Left Join on the field you picked. If you drag and join all of the other fields that you want to test as well and set them to Left Joins, by right clicking and setting the Join Properties, then it should pull out all of the records that have changed in any of those fields.

HTH

Peter
 
Upvote 0
Hi Peter, I am trying to do the same thing as foxhound and i used your suggestion of creating additional joins on all of the fields in both tables.

i am experiencing one problem. null values in both tables for the same field show up as a difference.

any suggestions on how to make a null value = a null value in a find unmatched query?

thanks,
fishingmachine
 
Upvote 0
Hi,

Null should always be Null, normally ...
Are you sure, that both fields have the same properties? It could be that there is a "space" in the field, and then the field has a value and is not null.
 
Upvote 0

Forum statistics

Threads
1,221,838
Messages
6,162,286
Members
451,759
Latest member
damav78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top