So, you want to use MERGE, eh?
So, you want to use MERGE, eh?
 

Please don't. Every time I see a question about MERGE, I scramble for the links I post to urge people to change their minds. So I put them together here.

If you insist on using MERGE, the biggest TL;DR is:

Please ALWAYS use HOLDLOCK on the target.

But for a long list of details, see these resources:

By: Aaron Bertrand

I am a passionate technologist with industry experience dating back to Classic ASP and SQL Server 6.5. I am a long-time Microsoft MVP, write at Simple Talk, SQLPerformance, and MSSQLTips, and have had the honor of speaking at more conferences than I can remember. In non-tech life, I am a husband, a father of two, a huge hockey and football fan, and my pronouns are he/him.