SQL Server: How to select all days in a date range even if no data exists for some days
You can use a recursive CTE to build your list of 30 days, then join that to your data –test select cast(’05 jan 2011′ as datetime) as DT, 1 as val into #t union all select CAST(’05 jan 2011′ as datetime), 1 union all select CAST(’29 jan 2011′ as datetime), 1 declare @start datetime=”01 jan … Read more