Are you allowed to exec stored procedures within a SQL CTE statement? I'm a bit new to sql cte queries...
No, sorry. SELECTs statments only
If you need to use stored proc output (result set), then it'd be a temp table
CREATE TABLE #foo (bar int...)
INSERT #foo (bar, ...)
EXEC myStoredProc @param1...
-- more code using #foo
You can also use table variable:
DECLARE @tbl TABLE(id int ,name varchar(500) ,...)
INSERT INTO @tbl
EXEC myprocedure @param ..
with cte as (
SELECT * FROM @tbl
)
select * from cte
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.