Hi Guys,
I have a With CTE table expression ,this cte gets the value from startdate and enddate
I need to insert this startdate and enddate into a table ,while inserting into table,i got the below error,
Derived table 'Datematrix' is not updatable because a column of the derived table is derived or constant.
below is the query i used,
declare @StartDate date='01/01/2013'declare @EndDate date='12/31/2013'
;WITH Datematrix(AllocationDate)
As
(
SELECT @StartDate AS AllocationDate
UNION ALL
SELECT DATEADD(D,1,AllocationDate) AS AllocationDate
FROM Datematrix WHERE AllocationDate<@EndDate
)
Insert into Datematrix(AllocationDate)
select * from Datematrix
any guys update this solution.
Thanks
Bhupesh.R