How to find new records in a table

  • Hi,

    I have a small question..I have 2 tables ..1 table is the copy of the other table...but one of those tables has extra records..how can we find those extra records?? Thanks in advance...

  • You can use either of these techniques:

    -- find all missing rows in table2

    SELECT ...

    FROM table1 t1

    LEFT JOIN table2 t2 ON t2.pk = t1.pk

    WHERE t2.pk IS NULL;

    Or, you can use EXCEPT

    SELECT col1, col2, col3, ... FROM table1

    EXCEPT SELECT col1, col2, col3, ... FROM table2;

    Jeff

    Jeffrey Williams
    “We are all faced with a series of great opportunities brilliantly disguised as impossible situations.”

    ― Charles R. Swindoll

    How to post questions to get better answers faster
    Managing Transaction Logs

  • gr8...thanks a lot...

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply