Something like thisdeclare @tbl as table(id int identity(1,1),leavestartdate datetime,leaveenddate datetime)insert into @tblselect '10-jan-2010','15-jan-2010' union allselect '20-jan-2010','22-jan-2010' union allselect '5-feb-2010','10-feb-2010' ;with cteas(select id,leavestartdate,leaveenddate,leavestartdate as leavedates from @tbl t1union allselect t2.id,t2.leavestartdate,t2.leaveenddate,c1.leavedates+1 from @tbl t2inner join cte c1 on c1.leavedates+1<=t2.leaveenddate and c1.id=t2.id)select id,leavedates from cte order by id --- ur where condition will come hereoption (maxrecursion 0)
PBUH