How to split records into a temp table?

  • Hi All,

    Here's the situation/problem:

    Say I have the following "Courses" table with these cols (vcCourseTitle, dtTripStart, dtTripEnd).

    EXAMPLE

    Intro to SQL | 2003-11-01 | 2003-11-02

    --------------------------------------------------

    Adv SQL Programming | 2003-11-03 | 2003-11-07

    --------------------------------------------------

    DTS | 2003-11-02 | 2003-11-05

    --------------------------------------------------

    SQL Relpication | 2003-11-04 | 2003-11-10

    --------------------------------------------------

    (total 4 records)

    I would like to create a single record in a temp table for EACH DAY the course is being held based on the table above:

    e.g.

    Intro to SQL | 2003-11-01

    -------------------------------------

    Intro to SQL | 2003-11-02

    -------------------------------------

    Adv SQL Programming | 2003-11-03

    -------------------------------------

    Adv SQL Programming | 2003-11-04

    -------------------------------------

    Adv SQL Programming | 2003-11-05

    -------------------------------------

    Adv SQL Programming | 2003-11-06

    -------------------------------------

    Adv SQL Programming | 2003-11-07

    -------------------------------------

    DTS | 2003-11-02

    -------------------------------------

    DTS | 2003-11-03

    -------------------------------------

    DTS | 2003-11-04

    -------------------------------------

    DTS | 2003-11-05

    -------------------------------------

    SQL Relpication | 2003-11-04

    -------------------------------------

    SQL Relpication | 2003-11-05

    -------------------------------------

    SQL Relpication | 2003-11-06

    -------------------------------------

    SQL Relpication | 2003-11-07

    -------------------------------------

    SQL Relpication | 2003-11-08

    -------------------------------------

    SQL Relpication | 2003-11-09

    -------------------------------------

    SQL Relpication | 2003-11-10

    -------------------------------------

    (total 18 records)

    Obviously I can figure out the duration with DATEDIFF and DATEADD to get the duration and add to the first dates, but can't figure out how to traverse the original table to create "slpit" the records in the first place.

    Any assistance would be GREATLY appreciated.

  • The same query is answered in the TSQL section

Viewing 2 posts - 1 through 1 (of 1 total)

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