how to check if a row was returned

  • I want to automate some little procedures. this involves checking if a query returns results, so i want to do something like:

    if ( select* from table where col1 = value >= 1 rows returned)

              do this stuff

    else

              do this other stuff

    end if

     

    How do i do this in sql server?

  • IF EXSITS (SELECT * FROM Whatever)

    BEGIN

    --at least one row

    END

    ELSE

    BEGIN

    --no rows

    END

  • simplicity! ! exactly what i needed. thank you very much.

  • Happy to help .

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

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