Skip to main content
Ben Nadel at InVision In Real Life (IRL) 2018 (Hollywood, CA) with: Johnathan Hunt
Ben Nadel at InVision In Real Life (IRL) 2018 (Hollywood, CA) with: Johnathan Hunt ( @JHuntSecurity )

Internal Query Processor Error: The Query Processor Ran Out Of Stack Space During Query Optimization

By on
Tags:

Wooohooo! I got a SQL server error that I have never seen before:

Internal Query Processor Error: The Query Processor Ran Out Of Stack Space During Query Optimization.

I am working on an old report for a client that originally had a small set of data and now has an ENOURMOUS set of data. Looks like it's time to start breaking a query up into smaller queries - give the SQL server less to worry about.

Reader Comments

1 Comments

Is it a coincidence that the filename of this page starts with "500"? I find that I sometimes get this error when combining more than 500 fields in one expression in a SQL Server query.

1 Comments

We received this error due to a bug that kept on appending items to a list that we used in an IN clause of a SQL Statement.
It blew up since the IN statement had 35,000 arguments.

Creating a temp table per the MS article is probably the best solution since you can throw a clustered index on the column.

This part of the MS article scared me a bit:
In some cases, SQL Server may actually shutdown as a result of the stack overflow.

I believe in love. I believe in compassion. I believe in human rights. I believe that we can afford to give more of these gifts to the world around us because it costs us nothing to be decent and kind and understanding. And, I want you to know that when you land on this site, you are accepted for who you are, no matter how you identify, what truths you live, or whatever kind of goofy shit makes you feel alive! Rock on with your bad self!
Ben Nadel