IF Statement based on Multiple SELECT Statements

  • Hi

    Basically, I'm attempting to write a statement based on multiple conditions. So, there will be 2 SELECT statements, IF the results of the first SELECT statement exist in the results of the second SELECT statement, then the script must execute a SP.

    Is this possible to do?

  • Yes, it is possible. However, for more information on how to do it, we need more information from you.

    Check the article linked on my signature to get better help.

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Luis,

    Thank you for the reply.

    I have though worked it out! I used a JOIN in the IF statement, If the results of the Join were > 0, the script executed the SP 🙂

  • wak_no1 (9/2/2013)


    Luis,

    Thank you for the reply.

    I have though worked it out! I used a JOIN in the IF statement, If the results of the Join were > 0, the script executed the SP 🙂

    How are you checking for NULLs?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Just wanted to add, this is a perfect use case for the EXISTS clause with a correlated sub query.

Viewing 5 posts - 1 through 4 (of 4 total)

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