• What severity are you using in your RAISERROR?

    It sounds like you don't have your BEGIN/END statements placed properly.  You should never be able to process both sides of an IF...THEN...ELSE statement.

    Also, I would use IF NOT EXISTS ( <subquery> ) rather than IF ( <subquery> ) IS NULL, for several reasons.
    1) It's more widely used.
    2) It's more accurate.  It can distinguish between failing to return a record and returning a record whose column contains a NULL value.
    3) It doesn't fail if the subquery returns multiple records
    4) It doesn't fail if the subquery returns multiple fields.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA