drop table #t
declare @d as date
set @d = @d1
select convert(varchar(10),dateadd(mm,number ,convert(varchar(8),@d,120)+‘01‘),120) as dt into #t
from master..spt_values
where type=‘P‘
and dateadd(mm,number,convert(varchar(8),@d,120)+‘01‘)<=dateadd(dd,-1,convert(varchar(8),dateadd(mm,DATEDIFF (mm,@d1,@d2)+1,@d),120)+‘01‘)
如有兴趣,加qq群围观:337335820