To print all the days of the week, you can use the recursive CTE. Here is the basic SQL Query to find all the week-days from
Monday to Saturday,
USE your_database
GO
WITH CTE_WeekDay(Number, WeekDays) AS
(
SELECT 0, DATENAME(DW, 0)
UNION ALL
SELECT Number+1, DATENAME(DW, Number+1) FROM CTE_WeekDay WHERE Number < 6
)
SELECT WeekDays FROM CTE_WeekDay
Output:
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To print all the days of the week, you can use the recursive CTE. Here is the basic SQL Query to find all the week-days from
MondaytoSaturday,Output: