Recently, while assisting a client with a Comprehensive Database Performance Health Check, we encountered a peculiar error when attempting to execute certain stored procedures. In this article, we will explore the error message “Error 8632 – Internal Error: An expression Services Limit Has Been Reached” and discuss how to resolve it.
After upgrading their SQL Server, our client experienced a performance regression issue with some queries and stored procedures. During our investigation, we discovered that a few queries were throwing the following error:
Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.
Initially, our instinct was to restart the SQL Server. However, considering the client’s business continuity requirements, a server restart was not feasible. Moreover, restarting the SQL Server is not recommended unless there are significant configuration changes or patch upgrades.
As part of our investigation, we made copies of the problematic stored procedures and found that each copy worked perfectly fine. This led us to conclude that the error was related to cached stored procedures.
The solution to this error turned out to be quite simple. We opened each of the stored procedures and recreated them with the same name. After doing so, everything started working as expected. In some cases, where a stored procedure contained another nested stored procedure, we had to recreate or recompile all the nested stored procedures to resolve the error.
Here is an example command that you can use to recompile a stored procedure:
EXEC sp_recompile N'SPName';
GOIf you have encountered this error before, we would love to hear about your experience and how you resolved it. Sharing your insights will help other readers who may be facing the same issue.
Feel free to connect with me on Twitter for further discussions and updates.