Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

Maximum amount of "If" statements and "Select CASE" Expand / Collapse
Posted Tuesday, October 14, 2008 2:26 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Friday, March 27, 2015 9:07 AM
Points: 217, Visits: 476
What is te maximum allowed nested "If" statements?
What is the Maximum allowed "CASE" in "Select CASE" statement.

I ask because I was using the MS SQL Server Migration Assistant an on one SP, I got the error saying...
"Errors: Some part of your SQL statement is nested too deeply."

Post #585787
Posted Wednesday, October 15, 2008 6:34 AM



Group: General Forum Members
Last Login: Yesterday @ 3:45 AM
Points: 17,172, Visits: 32,133
It's 10 levels in a CASE statement (here's the page in the local Books Online). I don't know of a limit on IF statements, but I think it's reasonably safe to say, if you need to worry about the limit, you're probably approaching the problem in an inefficient manner and need to step back and rethink the solution.

"The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood..." Theodore Roosevelt
The Scary DBA
Author of:
SQL Server Query Performance Tuning
SQL Server Execution Plans

Product Evangelist for Red Gate Software
Post #586129
Posted Wednesday, October 15, 2008 6:40 AM



Group: Administrators
Last Login: Yesterday @ 12:35 PM
Points: 34,363, Visits: 18,578
I agree with Grant. You might need to rethink the SP.

Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #586133
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse