Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Snapshot of Fact Table

$
0
0

I'm working on a snapshot of a Fact. The snapshot's purpose is to record changes of columns x,y, and z. If either x,y, or z change in the Fact, a new row should be added to the Snapshot and flag columns for the three columns should read Y or N (depending on which of the three columns changed).

My approach was to simply compare columns x,y, and z between extract date and dates from the day before(could be mins or secs before, nonetheless, I just want a variance in time).

My thought was to use a CASE statement in the source query:

SELECT CASE WHEN [x] <> (SELECT [x] FROM dw.dbo.FCT_TABLE WHERE LAST_MOD_DATE = DATEADD(DAY,-1,[LAST_MOD_DATE])) then 'Y' else 'N' end as FLAG_X 

But I don't seem to be getting the correct results. Any suggestions? Ultimately, I will apply the logic to SSIS



Viewing all articles
Browse latest Browse all 23857

Trending Articles