Script to compare two tables

  • Hi,

    Can I have a script to compare the two tables. Such that I can identify the missing rows of Table A in Table B, in the absece of any know key.

  • To compare without knowing what you are comparing doesn't make sense. You could try to look whether two tables are identical, but if the column names are different, then you need to provide some comparing pattern - which column in table A will be compared with which in table B.

  • Vladan's right, you MUST be able to identify what makes a row "unique"; it may be a combination of 5 fields, or it may be every field. that is the "key" you must identify before you can compare table to table to look for missing items.

    give us the table structure, and what you've identified that makes the row in the table as unique, and we can offer some good examples.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Is this not a cross-post of:

    http://www.sqlservercentral.com/Forums/Topic401899-8-1.aspx

    ??



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • Yes Adrian,

    You may count it as a cross post, but I put it under a different subject to know if there is any generic sql script that can compare two tables and find the unmatched rows without asking for a key or set of keys.

    Regards

Viewing 5 posts - 1 through 4 (of 4 total)

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