Merhaba,

Kaynak : When to use Common Table Expression (CTE)

How to create Temp Table with month columns based on date parameters?

Eğer sql ile recursive bir aylar yada yıllar listesi oluşturmak isterseni bu yöntemi kullanabilirsiniz

Günler döngüsü

DECLARE @StartDate DATE = '6/1/2013';

WITH Tablo(MDate) AS (
      SELECT @StartDate AS MDate
      UNION ALL
      SELECT DATEADD(dd, 1, MDate)
      FROM Tablo
      WHERE DATEADD(dd, 1, MDate) < DATEADD(mm, 1, @StartDate)
   )
SELECT MDate FROM Tablo
--temp tabloya al
SELECT  MDate INTO #tmp1 FROM Tablo

Aylar döngüsü

declare @start_date DATE = '20160101' 

;WITH CTE AS
(
    SELECT @start_date AS cte_start_date, DATENAME(month, @start_date) AS NAME , 0 AS Coun
    UNION ALL
    SELECT DATEADD(MONTH, 1, cte_start_date), DATENAME(month, DATEADD(MONTH, 1, cte_start_date)) AS NAME , 0 AS Coun
    FROM CTE
    WHERE DATEADD(MONTH, 1, cte_start_date)  < DATEADD(yy, 1, @start_date)  
)
Select * from CTE
--temp tabloya al
SELECT  Coun,Name INTO #tmp1 FROM CTE

İyi çalışmalar.