hi hope this helps .. this is not the complete solution
idea
.. please let me know if you want complete ..
drop create sample data
drop table SampleData
go
create table SampleData
(
Localcol date ,
id int
)
go
insert into SampleData select '2021-03-01', 1
insert into SampleData select '2021-03-02', 2
insert into SampleData select '2021-03-03', 3
insert into SampleData select '2021-03-07', 4
insert into SampleData select '2021-03-09', 5
select * from SampleData
; with tally_cte as
(
SELECT N=number+1 FROM master..spt_values WHERE type = 'P' and number+1 <= ( select max(DAY(Localcol)) from SampleData)
)
select 'SQL Output', * from tally_cte a left join SampleData b on a.N = DAY(Localcol)
; with tally_cte as
(
SELECT N=number FROM master..spt_values WHERE type = 'P'
) , xx_cte as
(
select min(Localcol) as mind , max(DAY(Localcol)) as maxd from SampleData
) , temp_cte as
(
select dateadd(dd,N,(select mind from xx_cte)) as OK from tally_cte where N < ( select maxd from xx_cte)
)
select
a.ok,b.id
from
temp_cte a
left join
sampledata b
on a.OK = b.Localcol