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)
 create rows from a single record

Author  Topic 

skillile
Posting Yak Master

208 Posts

Posted - 2002-02-01 : 09:04:24
I have seen something like this before but I cant seem
to find it again.

I want to split this table out into rows.

create table #time (time varchar(20), timecount int)
insert #time values('8:00:00', 2)
insert #time values('9:00:00', 3)
insert #time values('10:00:00', 2)

after the split I want 7 rows of data 2 8's, 3 9's, 2 10's

any suggestions.



slow down to move faster...

ToddV
Posting Yak Master

218 Posts

Posted - 2002-02-01 : 09:21:18
Do you have a tally or sequence table? This will do it.

create table #time (time varchar(20), timecount int)
insert #time values('8:00:00', 2)
insert #time values('9:00:00', 3)
insert #time values('10:00:00', 2)

--after the split I want 7 rows of data 2 8's, 3 9's, 2 10's

Select *
FROM #Time A
JOIN Tally B
ON A.timecount >= Tally



Go to Top of Page
   

- Advertisement -