Writing a line for each day of month???

  • I'm looking to write a record or each day of a month(or date range)

    I have a query that gets a name, and ID and write it to a temp table

    I'd like to generate output with  record for each date in the date range

    example

    I write a temp table with

    JimJames 901111

    Marymaples 90891

    *************************************

    I'd like output of

    1/1/23 JimJames 90111

    1/2/23 JimJames 90111

    1/3/23 JimJames 90111.....

    1/31/23 JimJames 90111

    1/1/23 Marymaples 90891

    1/2/23 Marymaples 90891

    1/3/23 Marymaples 90891.....

    1/31/23 Marymaples 90891.....

    Any ideas would be very much appreciated....

     

    Thnaks

    Joe

     

     

     

     

  • Does this thread help?

    https://www.sqlservercentral.com/forums/topic/how-do-i-write-a-record-for-each-day-in-a-date-range

    Michael L John
    If you assassinate a DBA, would you pull a trigger?
    To properly post on a forum:
    http://www.sqlservercentral.com/articles/61537/

  • Thank You Michael,

    The saddest part of the answer is I submitted the question 5 years ago!!!  LOL!!!!

    Shows how long I haven't used it...

     

    Thanks Again

     

     

  • jbalbo wrote:

    Thank You Michael,

    The saddest part of the answer is I submitted the question 5 years ago!!!  LOL!!!!

    Shows how long I haven't used it...

    Thanks Again

    I recommend that you don't make the same mistake that you made on that old thread.  😉  You posted the code you said you ended up using and I posted as to why that wasn't a good idea.

     

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

  • I see ur point,  but wouldn't I be safe if I ran it thru something like Ssrs using a date parameter?

     

  • jbalbo wrote:

    I see ur point,  but wouldn't I be safe if I ran it thru something like Ssrs using a date parameter?

    In a word, No. There are much better ways to do it.

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

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply