En metode er en rekursiv CTE:
with cte as (
select dateadd(day, 1 - day(@startdate), @startdate) as som,
eomonth(@startdate) as eom
union all
select dateadd(month, 1, som), eomonth(dateadd(month, 1, som))
from cte
where dateadd(month, 1, som) < @enddate
)
select *
from cte;
Hvis du vil have månedens navn, så kan du bruge datename(month, som)
.