Generate Weekdays in SQL Server

In this post, I am sharing simple script to generate weekdays in SQL server.

select  [DayId] = number
      , [DayName] = datename(dw, convert(datetime, cast(19000100 + number as varchar)))
from master.dbo.spt_values
where type = 'P' and number between 1 and 7
Result

Refer related posts

I am a Software Engineer and passionate programmer. Love working in SQL Server. Like participating in online technical communities like asp.net, MSDN, technical discussions and helping my friends, colleagues and others in their technical problems

Share this

Related Posts

Previous
Next Post »