This should get what you need. Remember to set maxrecursion if you use large date ranges in the range of / to the range.
http://sqlfiddle.com/#!6/68b32/233
declare @tblTemp TABLE (id int identity, fromDate datetime, toDate datetime) insert @tblTemp(fromDate, toDate) select '2014-01-01 12:00:00', '2014-01-02 12:00:00' union select '2014-04-01 12:00:00', '2014-04-02 12:00:00' ;with cte(i, f, t, e) as ( select id as i, fromDate as f, DATEADD(SS, -1, DATEADD(HH, 1, fromDate)) as t, toDate as e from @tblTemp union all select cte.i as i, DATEADD(SS, 1, cte.t), DATEADD(HH, 1, cte.t) as t, cte.e as e from cte where DATEADD(HH,1,cte.t) <= cte.e ) select i, f, t from cte order by i,f
Jim
source share