Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 5123

Derived table 'tablename' is not updatable because a column of the derived table is derived or constant.

$
0
0

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


Viewing all articles
Browse latest Browse all 5123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>