• Maybe this?

    SELECT d.ID

    FROM DATA d

    LEFT OUTER JOIN NEW_DATA n ON n.CODE = d.CODE AND n.CNAME=d.CNAME

    GROUP BY ID

    HAVING COUNT(*) = COUNT(n.CNAME);

    ____________________________________________________

    Deja View - The strange feeling that somewhere, sometime you've optimised this query before

    How to get the best help on a forum

    http://www.sqlservercentral.com/articles/Best+Practices/61537