Avatar of cbridgman
cbridgman
Flag for United States of America asked on

SQL SERVER SCRIPT - NESTED IF STATEMENTS

I am attempting to figure out a SQL script and am unclear how nested IF statements behave. An example of what I am trying to figure out is shown below. Assuming that the 1st IF statement is true (A='22222'), does the last IF statement (IF D = 'ORTGNV')  get evaluated regardless of the answer to the second IF statement (IF B='12345' and C='98765')? I've also attached a word copy of the script in case indentation is messed up.

IF A = ‘22222’
      BEGIN
            DO AAA
            IF B = ‘12345’ and C = ‘98765’
                  BEGIN
                        DO BBB
                  END
            ELSE
                  BEGIN
                        DO CCC
                  END
            IF D = ‘ORTGNV’
                  BEGIN
                        DO DDD
                  END
END
SQL-Script-Nested-IF.docx
Microsoft SQL ServerSQL

Avatar of undefined
Last Comment
cbridgman

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
Vitor Montalvão

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Jim Horn

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
SOLUTION
Pawan Kumar

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
⚡ FREE TRIAL OFFER
Try out a week of full access for free.
Find out why thousands trust the EE community with their toughest problems.
cbridgman

ASKER
Thank you very much for your timely help.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23