• This is great!! Thanks.

    Just one note, this part of the code below I think always resolves as true and I am not sure what it was supposed to do:

    (

    A.relatedTo is null

    or exists (

    select *

    from @TV as B

    where B.member = A.member and B.relatedTo is not null

    )

    )