How to print Months without using Loop

PandianS
Posted by PandianS under Sql Server category on | Points: 40 | Views : 2347
;WITH CTEs
AS
(
SELECT 0 AS [Month]
UNION ALL
SELECT [Month] +1 FROM CTEs WHERE [Month]<11
)

SELECT [Month]+1 [Month], DATENAME(M,DATEADD(M,[Month],'2011-01-01')) [Month Name] FROM CTEs
GO

Comments or Responses

Posted by: T.saravanan on: 2/21/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi PandianS,

Thanks for your sharing.
Its really nice and continue your great job.

Login to post response