• Then the where clause you have matches no rows.

    Probably because of this:

    IF @ADR3 IS NULL

    SELECT ADR1, ADR2, POSTAL_CODE

    FROM PAT_NAMES_ADDRESS

    WHERE CURRENT_ONE = RTRIM(@CURRENT_ONE)

    AND ADR1 = RTRIM(@ADR1)

    AND ADR2 = RTRIM(@ADR2)

    AND ADR3 = RTRIM(@ADR3)

    AND POSTAL_CODE = RTRIM(@POSTAL_CODE)

    As mentioned earlier in this thread, Column = NULL will return no rows (because NULL is never = to anything). You've run an IF checking whether or not @ADR3 IS NULL and if it is you're running a select which looks for rows WHERE ADR3 = NULL, which is never true.

    Might be worth doing some reading on NULL handling in SQL.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass