Friends,

In this post I am going to discuss, how to retrieve a month’s calendar by passing month and year as parameters to the script or procedure. The important point to note here is that if we use SQL Server Common Table Expression there is no need to create temporary table or table variable to store and then iterate over the days and dates of the month.

Before we proceed to our proc, copy the two functions below and run them in SSMS.

Copy and paste the below proc and run in SSMS.

Finally, execute the proc with required parameters.

1_SQL_Server_Fun_with_Common_Table_Expression_Creating_Calendar

 

Regards

Mridul Chandhok

Like us on FaceBook Follow us on Twitter

Join the fastest growing SQL Server group on FaceBook