update logic

I have a requirement to update fields between a staging table and a master table

So, for example if the value in the staging table differs from the master table update the master table. (eg firstname, lastname, address) The SQL for that would not be complicated.

The question i have is how could i determine if any changes where made?  For example if i have an update statement to set master.firstname = staging.firstname is there a way i could return if the update was made vs if they where identical to start with so no change was made.
vbnetcoderAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
How do know which record in the Staging table relates to which record in the Master table? Using that field (or fields), you can JOIN those tables, and then query for NULL values. You'd have to do that before you update the Master, of course.

For example, if you join on a CustomerID field:

SELECT * FROM StagingTable st LEFT OUTER JOIN MasterTable mt ON st.CustomerID=mt.CustomerID
WHERE mt.LastName<>st.LastName

This would tell you where the LastName field is different.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
hnasrCommented:
Try to list few records of each table, and show the expected output. A demo database including the tables populated with few test records, would be very helpful. Explain the process of getting the desired output
0
PatHartmanCommented:
There is a lot of missing detail that might be relevant to a good solution starting with how you are using the staging table - when are records added, when are they deleted, what prompts the updating of the main table and does that cause the record to be deleted from staging.  Are updates made to the main table outside of this process which would render it dangerous if you can't figure out exactly which table contains the valid data.
0
vbnetcoderAuthor Commented:
ty
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.