Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

Troubleshooting
Research
Professional Opinions
Ask a Question
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

troubleshooting Question

SQL SERVER SCRIPT - NESTED IF STATEMENTS

Avatar of cbridgman
cbridgmanFlag for United States of America asked on
Microsoft SQL ServerSQL
4 Comments1 Solution220 ViewsLast Modified:
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
ASKER CERTIFIED SOLUTION
Avatar of Vitor Montalvão
Vitor MontalvãoFlag of Switzerland imageIT Engineer
Commented:
This problem has been solved!
Unlock 1 Answer and 4 Comments.
See Answers