If I have multiple WHEN MATCHED statements in a MERGE statement, do they all execute if they\'re true?
My example:
DECLARE @X bit = NULL;
--skipping the
well, the answer is, do you really want to because if you do you would change a set based update to a row by agonising slow row update as in a set of rows you really would not know what columns changed on a record by record basis.
the question, therefore, is do you want to get performance? if so, make sure you have indexes that covering the
WHEN MATCHED TARGET.FIELD1 = SOURCE:FIELD1 AND TARGET.FIELD2 = SOURCE:FIELD2 ...
if not you are going to have to cursor over your updates after the merge using an INSTEAD OF
trigger...
Not good for speed, however, can work if you need to record who did what...
Happy Coding
Walter