這是我的前一個問題的延伸: Auto generating dates based on a table保存數據到表
我得到了它完美的作品
with n as (
select row_number() over (order by (select null)) - 1 as n
from master..spt_values
)
select t.*, dateadd(day, n.n, t.startDate) as thedate
from t join
n
on dateadd(day, n.n, t.startDate) <= t.endDate;
但是該決議,我想提出的通過將結果保存到表中來保持結果。可以持續數據嗎?我試過select into語句,但它沒有工作
整個語句是:收到
select into ABC
(
with n as (
select row_number() over (order by (select null)) - 1 as n
from master..spt_values
)
select t.*, dateadd(day, n.n, t.startDate) as thedate
from t join
n
on dateadd(day, n.n, t.startDate) <= t.endDate
)
錯誤是:
Msg 156, Level 15, State 1, Line 146
Incorrect syntax near the keyword 'into'.
Msg 319, Level 15, State 1, Line 148
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
Msg 102, Level 15, State 1, Line 168
Incorrect syntax near ')'.
如何將結果保存到一個表?
請發表您的完整的查詢插入查詢是不存在這個問題 –