Invalid operation. The connection is closed or Query too complex
Published Aug 04 2020 03:09 AM 6,509 Views

Scenario: When executed more than 325 columns in a select query the error bellow was thrown:

[110813] Invalid operation. The connection is closed.


The same query with fewer columns than that worked. So it seems it was hitting some kind of limit.


Once we got the request after some troubleshooting we found the following error on the logs: 

The service has encountered an error processing your request. Please try again. Error code 8632.


So it was not a matter of hard limit, but complexity and translation that may happen in any version of SQL Server.

I know this doc is SQL Server 2005, but the issue is the same. When the query is too complex it must be simplified. So SQL does not map de number of expressions directly.  Using  the doc words:

"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 solution was simplified the query text. Some functions were added on Select statement, SQL query text was simplified and the query worked after that.


That is it!



UK Engineer


Version history
Last update:
‎Aug 04 2020 03:08 AM
Updated by: