The T-Sql Merge statement, introduced in SQL 2008, is powerful, versatile, and performant. However, it is also one of T-SQL’s least understood statements. Most DBAs know they can use it to insert, update, and delete data in a target table in a single transaction, which generally outperforms separate statements. Fewer know, however, that it can be used to load slowly changing dimensions, facilitate auditing, as well as other uses. I briefly discussed how to use Merge some time ago, but I wanted to take a deeper dive into it because it is so darn usefull.
Though the statement is documented on many sites, many tend to cover it tersely or are little more than variations on Books Online, which I find difficult to read and absorb. So, in the following articles, we’ll cover the following basic topics.
- This post represents my original attempt, and I leave the link here for tracking purposes, but most people should skip it in favor of the second link.
What is the Merge statement and how do you use it? - Writing T-SQL Merge Statements the Right Way
- Using the Output Clause with T-SQL Merge
- What exactly are Dimensions and Why do They Slowly Change?
- How to Properly Load Slowly Changing Dimensions using T-SQL Merge
- Related: Loading Dimensions Historically
- Related: Extracting Historical Dimension Records using T-SQL
- Data Warehouse Initial (Historical) Dimension Loading With T-SQL Merge
[…] post is the second in a series called Have You Got the Urge to Merge? and is a follow up to Writing T-SQL Merge Statements the Right Way. If you just happened upon this […]
[…] I was writing the articles on handling Slowly Changing Dimensions with T-SQL Merge, I realized that some background on […]
[…] Data Warehouse. Consequently I see a lot of confusion on the subject. Before we go farther down the Urge to Merge Series, I thought it would be beneficial to define the concept with some visual […]
[…] with many of my Urge to Merge Series articles, this one will be presented in layers. In this case, each layer is actually a fully […]
Very nice series. Loved it. Thanks.