MSSQLSERVER_8632

Applies to: yesSQL Server (all supported versions)

Details

Attribute Value
Product Name SQL Server
Event ID 8632
Event Source MSSQLSERVER
Component SQLEngine
Symbolic Name QUERY_EXPRESSION_TOO_COMPLEX
Message Text Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.

Explanation

Error 8632 is raised when you run a query in SQL Server that contains a large number of identifiers and constants in a single expression. An error message like the following is reported to the user:

Server: Msg 8632, Level 17, State 2, Line 1
Internal error: An expression services limit has been reached. Please look for potentially complex expressions in your query, and try to simplify them.

Cause

This issue occurs because SQL Server limits the number of identifiers and constants that can be contained in a single expression of a query. This limit is 65,535. For example, the following query only has one expression:

select a, b + c, d + e

This expression retrieves all five columns, calculates the addition operators, and sends three projected results to the client.

The test for the number of identifiers and constants is performed after SQL Server expands all referenced identifiers and constants. For example, the following items may be expanded:

  • The asterisk (*) in the select list
  • A view
  • A computed column definition

If the number after the expansion exceeds the limit, the query cannot run.

User action

To work around this issue, rewrite your query. Reference fewer identifiers and constants in the largest expression in the query. You must make sure that the number of identifiers and constants in each expression of the query does not exceed the limit. To do this, you may have to break down a query into more than one single query. Then, create a temporary intermediate result.