Call a Stored procedure in SQL CTE

user167698 picture user167698 · Jun 13, 2011 · Viewed 22.9k times · Source

Are you allowed to exec stored procedures within a SQL CTE statement? I'm a bit new to sql cte queries...

Answer

gbn picture gbn · Jun 13, 2011

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