.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> SQL Query >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

How to print Months without using Loop

Posted By:Pandian       Posted Date: February 18, 2011    Points: 15    Category: SQL Query    URL: http://www.dotnetspark.com  

This sqmple code will show how to Print Months without using Loop in sql server.
 

;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

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply

    Read also another Resources from the same Author

Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend