• Jason-299789 (9/4/2012)


    Jeff Moden (9/3/2012)


    rka (9/2/2012)


    DateKey has to be in the format YYYYMMDD

    In SQL Server, that's a pretty insane requirement because that would make a character based date. Since you're using SQL Server 2008, you should either use DATETIME or DATE datatypes for such a thing.

    I strongly recommmend you talk to the people that designed the table and suggest that they should probably change it.

    As for actually building the table... what have you tried that's not working?

    Jeff I agree its pretty insane,

    But I've seen this especially if the YYYYMMDD is converted to an INT eg 20120101 = 20,120,101.

    Its been a frequent topic of discussion on various DW projects that I've worked on, prior to the Date Data type most of the calendar dims used the DateTime with the PK/SK column a CAST(CalendarDate as Int), again a pretty nasty way of doing this especially if you have a time element due to the rounding issues.

    However, since 2008 I've been converted to Date Data type as the PK/SK and it seems to work very well.

    NP. Thanks for the feedback. I have to ask again, though... what have you tried that isn't working in your efforts to build this table?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)