FIX: Error when you execute a Transact-SQL query that contains a long case statement in SQL Server 2012

Applies to: SQL Server 2012 DeveloperSQL Server 2012 EnterpriseSQL Server 2012 Standard More

Symptoms


Assume that you execute a Transact-SQL query in Microsoft SQL Server 2012. When the query contains a long case statement, the query fails. Additionally, you receive the following error:
Msg 8631, Level 17, State 1, Line 7
Internal error: Server stack limit has been reached. Please look for potentially deep nesting in your query, and try to simplify it.

Resolution


The issue was first fixed in the following cumulative update of SQL Server.

Cumulative Update 2 for SQL Server 2012 SP2

Cumulative Update 11 for SQL Server 2012 SP1

Status


Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.