Great article, just what I needed. Thanks
I made a slight modification in the CSD2 variant, just for security, to avoid ererroneous data, when the procedure is executed on an earlier day, than the last update.
I admit, this does not happen when using GETDATE() to set today, but my procedure has a date input, so I decided to be sure no updates are made on records which have ValidFrom > @Today.
So I added a statement to the WHEN MATCHED condition:
WHEN MATCHED
AND IsCurrent = 1
AND ValidFrom <= @Today --Never allow updates to overwrite future records
AND (ISNULL(DST.ClientName,'') <> ISNULL(SRC.ClientName,'')
...
Thanks once more
Herman