• Do you have the value NULL in column client_accountno? It seems that you have it. You have to take into account NULLs. Check the code bellow that shows it:

    --Creating the tables

    create table Demo (I INT NULL)

    go

    create table Demo2 (I INT NULL)

    go

    --Inserting the data

    insert into Demo (I)

    select 1 union select 2

    go

    insert into Demo2 (I)

    select 1 union select 3

    go

    --At this point Demo2 does not

    --contain the value NULL, so this should work

    select * from Demo

    where I not in (select I from Demo2)

    select * from Demo

    where not exists (select Demo2.I from Demo2 where Demo2.I = Demo.I)

    --After inserting the value Null the first query

    --won't return any records

    insert Demo2 (I) values (NULL)

    select * from Demo

    where I not in (select I from Demo2)

    --I need to exclude the value Null from the subquery

    select * from Demo

    where not exists (select Demo2.I from Demo2 where Demo2.I = Demo.I)

    --cleanup

    drop table Demo

    drop table Demo2

    Adi

    --------------------------------------------------------------
    To know how to ask questions and increase the chances of getting asnwers:
    http://www.sqlservercentral.com/articles/Best+Practices/61537/

    For better answers on performance questions, click on the following...
    http://www.sqlservercentral.com/articles/SQLServerCentral/66909/