declare @dt1 as datetime declare @dt2 as datetime set @dt1 = '2008-01-01' set @dt2 = '2009-01-01' ;with t as (select @dt1 as y union all select dateadd(m,1,y) from t where y <@dt2) select * from t
declare @dt1 as datetime declare @dt2 as datetime set @dt1 = '2008-01-01' set @dt2 = '2009-01-01' ;with t as (select @dt1 as y union all select dateadd(m,1,y) from t where y <@dt2) select * from t