Slowly Changing Dimensions

UDA
Enthusiast

Slowly Changing Dimensions

Hi,

I get the basics of SCD's. Type 1 and type 2. I m just having trouble with how to implement the SQL. Could anyone please provide a SQL example as to how Type 1 and 2 SCD's would be implemented?

THanks,
1 REPLY
Enthusiast

Re: Slowly Changing Dimensions

Well from a theoretical standpoint, this is one approach:

1) Load your 'new' data into a staging table
2) Use a SQL Minus operator to detect changes from this time period to the last (see SQL Functions, Operators, Expressions and Predicates PDF) and put only the changed records in a temp table.
3) Depending on your need, use the records in the temp table from (2) to either perform scd type 2 or scd type 3 logic.

Hope this helps.

Walter