When we use “Slowly changing Dimension” in
our project we used some steps, that is the below:
Step1: Create source table
CREATE TABLE [dbo].[EmployeeSRC](
[Eid] [int] NULL,
[Ename] [varchar](50) NULL,
[Salary] [int] NULL,
[Date] [date] NULL
) ON [PRIMARY]
Step2: Create Destination table
CREATE TABLE [dbo].[DimEmployee](
[Eid] [int] IDENTITY(1,1) NOT NULL,
[Ekey] [int] NULL,
[Ename] [varchar](50) NULL,
[Salary] [int] NULL,
[EffectiveFromDate] [date] NULL,
[EffectiveToDate] [date] NULL
) ON [PRIMARY]
Step3: Add “DataFlowTask” in Control Flow
Step4: Double click “DataFlowTask”, then add OLEDB Source Task
Step 5: After add Slowly Changing Dimension Task
Step6: Then double click step5 and set a Business key columns
If you want to remove the data from Destination table based on the source, you add Execute SQL Task.
And use the below code
DELETE FROM dimemployee
WHERE ekey NOT IN (SELECT eid FROM employeesrc)
Step1: Create source table
CREATE TABLE [dbo].[EmployeeSRC](
[Eid] [int] NULL,
[Ename] [varchar](50) NULL,
[Salary] [int] NULL,
[Date] [date] NULL
) ON [PRIMARY]
Step2: Create Destination table
CREATE TABLE [dbo].[DimEmployee](
[Eid] [int] IDENTITY(1,1) NOT NULL,
[Ekey] [int] NULL,
[Ename] [varchar](50) NULL,
[Salary] [int] NULL,
[EffectiveFromDate] [date] NULL,
[EffectiveToDate] [date] NULL
) ON [PRIMARY]
Step3: Add “DataFlowTask” in Control Flow
Step4: Double click “DataFlowTask”, then add OLEDB Source Task
Step 5: After add Slowly Changing Dimension Task
Step6: Then double click step5 and set a Business key columns
Step7: then
Step8: next
Step9: next
Step10: then unselected “Enable inferred member support”
option
If you want to remove the data from Destination table based on the source, you add Execute SQL Task.
And use the below code
DELETE FROM dimemployee
WHERE ekey NOT IN (SELECT eid FROM employeesrc)




