Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...I love this site! It's so nice to know that there are so many people out there who are willing to share their knowledge..."

Geography

Where in the world do Tek-Tips members come from?
FlaBusInt (IS/IT--Management)
9 May 07 15:02
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:

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!
FlaBusInt (IS/IT--Management)
9 May 07 16:29
Never mind!  After playing with a bunch of increasingly complex (and ineffective) transforms, I realized I could just use the Lookup Transform against my DimTime dimension table.  It added about 2 seconds of overhead to my SSIS package.
MDXer (TechnicalUser)
10 May 07 16:57
THe lookup transform is one way if your key is in that format  you could also use a derived collumn that uses DatePart() and conctinates the Year Month and Day Dateparts into a single stream.  


Personally my datekeys are a Floor(Cast(DateCol as float))
which I can do as part of the Extract.

Paul
---------------------------------------
Shoot Me! Shoot Me NOW!!!
                           - Daffy Duck

FlaBusInt (IS/IT--Management)
17 May 07 10:44
Just thought I'd pass this along - I ran into a better way to create my smart date key in SQL.  Now I can do it as part of the extract rather than using a lookup:

CODE

SELECT
cast(convert(char(8),stage.ApptDate,112) as int)

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close