This article is contributed. See the original author and article here.

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.”

https://support.microsoft.com/en-us/help/913050/error-message-when-you-run-a-query-in-sql-server-2005-internal-error-a

 

 

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!

 

Liliam 

UK Engineer

 

Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.