日期:2014-05-18 浏览次数:20664 次
;with t as (select cast('2011-01-01'as datetime) as dt union all select dt+1 from t where dt+1<='2011-12-31') select * from t option(maxrecursion 0)
------解决方案--------------------
declare @startdate datetime,@enddate datetime set @startdate='2011-01-01' set @enddate='2011-12-31' select convert(varchar(10),dateadd(day,number,@startdate),120) from master..spt_values where datediff(day,dateadd(day,number,@startdate), @enddate)>=0 and number>=0 and type='p'