February 25, 2016 at 11:39 am
I have a source and target table. target table is being updating weekly. Using Merge when match is found, i only want to update those columns where value is changed rather than updating every column. How it can be done?
Any help will be helpful.
February 25, 2016 at 12:08 pm
Are you merging or you're just updating? If you're just updating, use UPDATE.
Here are some general examples:
UPDATE t
SET value = s.value
FROM TargetTable t
JOIN SourceTable s ON t.id = s.id
AND t.value <> s.value;
MERGE INTO TargetTable t
USING (SELECT id, value FROM SourceTable) AS s
ON t.id = s.id
WHEN MATCHED AND t.value <> s.value
UPDATE SET value = s.value;
February 26, 2016 at 1:23 pm
Is this helpful?
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply