Posts

Showing posts from January, 2020

MERGE - A Neat Way to Do Type 2 Load

Image
In this post we'll introduce a way to load data into a Type 2 table in a neat and beautiful way. If you don't know what a Type 2 table (or Slow Changed Dimension Type 2) is, please read the book 'Data Warehouse Toolkit' by Ralph Kimball for details. Firstly, we use the below script to generate two temp tables and populate data into them. CREATE TABLE #Target        (               [ID] int               , [Name] varchar ( 16 )               , [IsEnabled] bit        ) INSERT INTO #Target VALUES ( 1 , 'Pepper' , 1 )        ,( 2 , 'Chilli' , 1 )        ,( 3 , 'Paprika' , 1 ) CREATE TABLE #Source        (  ...