Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 How to Structure History in a Table?

Author  Topic 

dlorenc
Posting Yak Master

172 Posts

Posted - 2010-03-02 : 15:40:03
Every week I clear a table containing current fiscal year records from an operational system; and insert updated records into the same table. User then can write reports, and analysis queries against this datamart, without impacting the operational application.

For analysis, I would like to produce two datasets, one from the current month's records, and one from the previous month's records.

My problem is I clear the old table, and add records from the current application database...so I need to come up with a scheme to keep history in the datamart..not just recreate it weekly... (I know, smacks of datawharehouse)...

An application record has an 'entered' date field, showing when it was created, and a 'modified' date field...showing when it was last updated. I also create a field called 'ReportPeriod' which is set to the first day of the month of the current month....

I am thinking I need a new field 'Snapshot date' that is set to the date when I update the datamart from the operational system...and do appends instead of inserts....

then when I pull my datasets, I have a complex key of reportperiod&snapshotdate ... comments?
   

- Advertisement -