Did you try this:
DECLARE @strQuery VARCHAR(MAX) = ''
SET @strQuery = @strQuery0 + @strQuery1 + @strQuery2 + @strQuery3 + @strQuery4;
EXECUTE(@strQuery);
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hi All,
I have received below error during executing attached query.
The query processor ran out of stack space during query optimization. Please simplify the query.
It properly worked for @lineCount = 500 but yesterday we received @lineCount = 1200 first time
and it gives the error.
Please help me resolve this issue
Thanks
Did you try this:
DECLARE @strQuery VARCHAR(MAX) = ''
SET @strQuery = @strQuery0 + @strQuery1 + @strQuery2 + @strQuery3 + @strQuery4;
EXECUTE(@strQuery);
Hi @Amit Kadam
Simplify the query by breaking the query into multiple queries along the largest dimension.
First remove any query elements that are not really necessary, then try adding a temp table and splitting the query in two.
Merely moving a part of the query to a subquery or function or common table expression is insufficient, since they get recombined by the Transact-SQL compiler.
Best regards,
Cosmog Hong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.