Table compare

  • Hello, I have two tables I am trying to compare as I have created a new procedure to replace an old one and want to check if the new procedure produces similar results.

    The problem is that when I run my compare I get false matches. Example:

    CREATE TABLE #ABC (Acct VARCHAR(10), Que INT);

    INSERT INTO #ABC VALUES

    ('2310947',110),

    ('2310947',245);

    CREATE TABLE #DEF (Acct VARCHAR(10), Que INT);

    INSERT INTO #DEF VALUES

    ('2310947',110),

    ('2310947',245);

    SELECT #ABC.*

    FROM #ABC

    INNER JOIN #DEF ON #ABC.Acct = #DEF.Acct

    WHERE #ABC.Que <> #DEF.Que;

    DROP TABLE #ABC;

    DROP TABLE #DEF;

    Which gives me two records when I really do not want any as the tables are identical.

    Any suggestions?

    Thank you

  • You need to join your example tables on both columns.

    You might also look at using EXCEPT. Something like

    select acct, que

    from #ABC

    except

    select acct, que

    from #DEF

  • Thank you, mcx5000.

    The EXECPT might just be what I was looking for. I have not used it very often so do not think of it.

    Thanks again,

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

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