Select 12 months number and name from sql server

Select 12 months number and name from sql server

Display months number..............

;WITH months(Month_Number) AS
(
    SELECT 1
    UNION ALL
    SELECT Month_Number+1 
    FROM months
    WHERE Month_Number < 12
)
select *
from months;

 

Display months name .................

;WITH months(Month_Number) AS
(
    SELECT 0
    UNION ALL
    SELECT Month_Number+1 
    FROM months
    WHERE Month_Number < 12
)
SELECT LEFT(DATENAME(MONTH,DATEADD(MONTH,-Month_Number,GETDATE())),3) AS [month]
FROM months;

 

2021-10-03