I have a situation in which a fact table is loaded every day.
There are two SSIS packages that load this table.
1) Package1_FullLoad.dtsx - runs every Sunday, with a full refresh
2) Package2_DailyLoad.dtsx - runs on all days except Sundays, deleting and loading the data for the past 14 days alone.
Now, the full load package (Package1_FullLoad.dtsx) has an Execute SQL Task, truncates all the rows from the fact table.
Then the Data Flow loads the fact table from scratch.
In this case the identity value of the fact table starts from 1 and increments by 1, and this is fine, no issue.
However, for the daily load package (Package2_DailyLoad.dtsx),
after the DELETE statement (which deletes data for the past 14 days alone), in the Execute SQL Task, I set this code:
DBCC CHECKIDENT('dbo.FactTable', RESEED,1)
DBCC CHECKIDENT('dbo.FactTable', RESEED)
Then I run the data flow to load the data, which inserts only data corresponding to the past 14 days.
Say there are 10 rows in the fact table after the full load (take as an example to illustrate the situation better), and 3 are deleted today and 5 are to be inserted today (insertion and deletion to be done by the daily load package today), the new identity
value must start from 8 and end at 12. Instead I see the new identity value starting at 11 and ending at 15.
I do not see any impact in this DBCC code in SSIS Execute SQL Task.
This DBCC code works fine in the SSMS on the database side.
Any idea on how to fix this issue?