---
title: "SQL Query to print all the month name."  
description: "SQL Query to print all the month name."  
author: "Revati S Misra"  
published: 2024-12-20  
updated: 2024-12-20  
canonical: https://www.mindstick.com/forum/161070/sql-query-to-print-all-the-month-name  
category: "mssql server"  
tags: ["mssql server", "sql server", "sql"]  
reading_time: 1 minute  

---

# SQL Query to print all the month name.

Write an SQL Query to print all the month names of a year.

## Replies

### Reply by Ashutosh Patel

You can print all the names of the months in the SQL server by using SQL Recursive CTE.

Here is the simple SQL Query,

```plaintext
USE your_database
GO
WITH CTE_MonthName(Number, MonthName ) AS
(
SELECT 0, DATENAME(MONTH, DATEADD(MONTH, 0, DATEFROMPARTS(YEAR(GETDATE()), 1, 1)))
UNION ALL
SELECT Number+1, DATENAME(MONTH, DATEADD(MONTH, Number+1, DATEFROMPARTS(YEAR(GETDATE()), 1, 1))) FROM CTE_MonthName WHERE Number < 11
)
SELECT MonthName FROM CTE_MonthName
```

## Output:

![SQL Query to print all the month name.](https://www.mindstick.com/mindstickforums/f5b7eda0-39b6-4ac7-ae6a-89a7e7acd6e6/images/2a712cb8-dcfe-46e2-a187-353ed5888a26.png)

Also, Read: [SQL Query to print Week days.](https://www.mindstick.com/forum/161069/sql-query-to-print-week-days)


---

Original Source: https://www.mindstick.com/forum/161070/sql-query-to-print-all-the-month-name

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
