这是我的前一个问题的延伸: 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 ')'.
如何将结果保存到一个表?
请发表您的完整的查询插入查询是不存在这个问题 –