0
votes

Wasn't really able to find the answer anywhere for this, trying to understand when using the Merge command, if there is a row in my target table that is identical to my source table if it will update the values anyways from the source table.

In other words I have the following tables:

enter image description here

Will the source table still run an update on the target table in the above situation?

What I'm trying to do, if the target table equals source table, do nothing. Only apply the update/insert/delete functions if there is a true difference between the tables.

AND BONUS POINTS, IF POSSIBLE, only run an update on the specific column that is different not the entire row.

I'm afraid that currently when the "matched" condition is met, it will update the values regardless if they are in fact the same.

Now, I understand even if the values are updated they wont be incorrect, but I'm trying to keep track of true adjustments to table via insert/update/delete operations.

MERGE target_table USING source_table
ON merge_condition
WHEN MATCHED
    THEN update_statement
WHEN NOT MATCHED
    THEN insert_statement
WHEN NOT MATCHED BY SOURCE
    THEN DELETE;
1

1 Answers

1
votes

It appears it still is marked as updated in terms of log activity, but the data itself doesn't update (minus a few situations noted on the link below). Please see this question on the DBA Stack Exchange

DBA StackExchange - Non-Updating Updates

The Impact of Non-Updating Updates