Maximum amount of "If" statements and "Select CASE"

  • 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."

    Thanks

  • 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

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • I agree with Grant. You might need to rethink the SP.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply