Specifically, why we should avoid using the MERGE statement.
I was going to make a quick blog post on why we should avoid using the MERGE statement in hopes of convincing my fellow co-workers to avoid them (regardless of what database vendor we are using). Really I was just going to provide a bunch of internet links over to Aaron Bertrand’s and Michael J Swart’s blog postings on this subject, but I found Aaron has already created all the links here.
Besides the usual bugs, performance issues, and concurrency issues that are associated with the MERGE statement, I’m old school and like to separate my MERGEs into their respective INSERT, UPDATE, and DELETE statements for better readability. I find the MERGE syntax to be a little clunky and does not offer the readability that is often touted as a benefit to them.
And just to be clear, I don’t recommend using MERGE statements on any database platform. The bugs listed below are for SQL Server, but the issues with concurrency and performance will be true for any database vendor.