【发布时间】:2022-10-04 22:46:20
【问题描述】:
在 SQL Server 中,我可以使用 with 语句来简化如下查询:
with x as (select 1 as a)
select * from x
但是如果我想要使用的查询实际上是一个存储过程呢?
with x as (exec p_queryComplexSP 12345, 0, null,'D+0','D+1095','Hour','GMT', 1)
select * from x
-- fails: SQL Error [156] [S0001]: Incorrect syntax near the keyword 'exec'.
有没有正确的方式来表达这个查询?
【问题讨论】:
标签: sql-server stored-procedures