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 /en-us/help/2983175
Cumulative Update 11 for SQL Server 2012 SP1 /en-us/help/2975396
Each new cumulative update for SQL Server contains all the hotfixes and all the security fixes that were included with the previous cumulative update. Check out the latest cumulative updates for SQL Server:
Status
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section.