Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to split records into a temp table?

Author  Topic 

al_nick
Starting Member

1 Post

Posted - 2003-10-05 : 11:51:24
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 use DATEADD 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.

robvolk
Most Valuable Yak

15732 Posts

Posted - 2003-10-05 : 12:07:41
Try this:

http://www.sqlteam.com/item.asp?ItemID=3332
Go to Top of Page
   

- Advertisement -