Your technology certification is waiting. Enroll in Cloud Class ®
DECLARE @FromDate DATETIME, @ToDate DATETIME
SELECT @FromDate='1/1/2012',@ToDate ='1/2/2012';
WITH TimeData (time_started) AS
SELECT @FromDate AS datetime
SELECT DATEADD(hh, 1, time_started) FROM TimeData WHERE time_started < @ToDate
SELECT time_started, DATEADD(hh,1,time_started) AS time_ended INTO #Time FROM TimeData OPTION (MAXRECURSION 0);
SELECT * FROM #Time
Select a.time_started, a.time_ended, b.room
FROM #Time a
LEFT JOIN rcenter_mdata as b on a.time_started <= b.time_started and b.time_started < a.time_ended
and b.date_started = '08/09/2012'
Open in new window
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.