Got the Urge to Merge?

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.

  1. 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?
  2. Writing T-SQL Merge Statements the Right Way
  3. Using the Output Clause with T-SQL Merge
  4. What exactly are Dimensions and Why do They Slowly Change?
  5. How to Properly Load Slowly Changing Dimensions using T-SQL Merge
  6. Related: Loading Dimensions Historically
  7. Related: Extracting Historical Dimension Records using T-SQL
  8. Data Warehouse Initial (Historical) Dimension Loading With T-SQL Merge

5 comments to Got the Urge to Merge?

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>