• pietlinden (4/20/2014)


    If you're using a normal database and not an SSAS cube, then you can use a Calendar table. Here's the article on it: http://www.sqlservercentral.com/articles/T-SQL/70482/

    Basically, the Calendar table has a series of dates, and a bunch of other derived columns (hey, they're static data you can filter on!) you just join from your table to the date key in the Calendar table and then away you go!

    "It Depends". I find that some simple formulas are, many times, much faster, shorter, and easier to write than using Calendar Tables.

    --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)