Tengo una consulta MS SQL CTE a partir de la cual quiero crear una tabla temporal. No estoy seguro de cómo hacerlo, ya que da un Invalid Object name
error.
A continuación se muestra la consulta completa para referencia
SELECT * INTO TEMPBLOCKEDDATES FROM
;with Calendar as (
select EventID, EventTitle, EventStartDate, EventEndDate, EventEnumDays,EventStartTime,EventEndTime, EventRecurring, EventStartDate as PlannedDate
,EventType from EventCalender
where EventActive = 1 AND LanguageID =1 AND EventBlockDate = 1
union all
select EventID, EventTitle, EventStartDate, EventEndDate, EventEnumDays,EventStartTime,EventEndTime, EventRecurring, dateadd(dd, 1, PlannedDate)
,EventType from Calendar
where EventRecurring = 1
and dateadd(dd, 1, PlannedDate) <= EventEndDate
)
select EventID, EventStartDate, EventEndDate, PlannedDate as [EventDates], Cast(PlannedDate As datetime) AS DT, Cast(EventStartTime As time) AS ST,Cast(EventEndTime As time) AS ET, EventTitle
,EventType from Calendar
where (PlannedDate >= GETDATE()) AND ',' + EventEnumDays + ',' like '%,' + cast(datepart(dw, PlannedDate) as char(1)) + ',%'
or EventEnumDays is null
order by EventID, PlannedDate
option (maxrecursion 0)
Agradecería un punto en la dirección correcta o si puedo crear una tabla temporal a partir de esta consulta CTE