I have a fact table that I currently write about 1M records to as part of a nightly table load. I am using SSIS to pull the records over to my BI database as a staging table, which takes about 1 minute. I then run a stored procedure that copies the rows from the staging table into my final fact table. The primary purpose of the stored proc is to convert the five date fields (smalldatetime) in the staging table into a smart date key (int - yyyymmdd). The stored proc adds another 30 - 40 minutes to the process.
My question - would it be faster to create the date key as part of the SSIS Data Flow task, and, if so, what transform would I use? I've tried doing it in a Derived Column transform, but I can't get the month and day leading zeros to work. I've got to believe that someone has solved this issue before, but I can't find any references to it.
The select statement in the stored proc that I use for the transform is:
where dbo.PadString_fn is a user-defined function that adds the leading '0' to months and days that are only one digit.
Thanks!
My question - would it be faster to create the date key as part of the SSIS Data Flow task, and, if so, what transform would I use? I've tried doing it in a Derived Column transform, but I can't get the month and day leading zeros to work. I've got to believe that someone has solved this issue before, but I can't find any references to it.
The select statement in the stored proc that I use for the transform is:
Code:
SELECT
convert(char(4),Year(stage.ApptDate))
+ dbo.PadString_fn(convert(varchar(2),Month(stage.ApptDate)),'0',2,0)
+ dbo.PadString_fn(convert(varchar(2),Day(stage.ApptDate)),'0',2,0)
where dbo.PadString_fn is a user-defined function that adds the leading '0' to months and days that are only one digit.
Thanks!