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
 Transact-SQL (2000)
 How to blow up a range into multiple records

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2004-06-07 : 07:31:03
Mona writes "Hi,
i have a table of employees with a from-date, to-date range. i want to be able to return all the days that are included in the range, using a query.
Thank you for any help"

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2004-06-07 : 08:12:16
declare @StDate datetime

declare @EndDate datetime

select @StDate = [from-date], @EndDate = [to-date] from employees where empid = 1

while @StDate <= @EndDate
begin
insert into @tblDates
select @StDate
set @StDate = dateadd(d,1,@StDate)
end

select adate from @tblDates



Go to Top of Page
   

- Advertisement -