While executing a stored procedure, I am getting this error message,
Msg 8621, Level 17, State 2, Line 1 The query processor ran out of stack space during query optimization. Please simplify the query.
asked Jan 27 '12 at 10:40 PM in Default
This is a rare internal error (the optimizer contains logic to avoid stack problems in the most common cases). Related errors can occur as a result of having too many
In any case, the error message is pretty specific about the problem and what you should do about it. Encountering this sort of error is usually a pretty reliable sign that your query is too complex - probably for humans as well as optimizers. Find a way to break the logic into simpler stages.
answered Jan 28 '12 at 02:26 AM