• cs_source (2/28/2015)


    I have a table that has hotel guests and their start stay date and end stay date, i would like to insert into a new table the original information + add all days in between.

    CREATE TABLE hotel_guests

    (

    [guest_name] [varchar](25) NULL,

    [start_date] [date] NULL,

    [end_date] [date] NULL,

    [comment] [varchar](255) NULL

    )

    CREATE TABLE hotel_daily_visit

    (

    [guest_name] [varchar](25) NULL,

    [effective_date] [date] NULL,

    [start_date] [date] NULL,

    [end_date] [date] NULL,

    [comment] [varchar](255) NULL

    )

    INSERT INTO hotel_guests (guest_name,start_date,end_date)

    VALUES ('jim','2015-02-01','2015-02-15','cleaning');

    All help is much appreciated!

    My question now would be, why do you want to expand the data like this? What purpose will it be used for. I ask because it may be totally unnecessary to perform this data duplication.

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