Comparing rows between two tables

  • I have two tables that I have to compare to get the differences.

    Table Design

    Service varchar(40)

    CustomerName varchar(50)

    ConnectDate datetime

    Disconnect Date datetime

    There is no key nor index - I need to find the records that are in table1 that are not in table2 and vice versa. Any recommendations on how to do this ?

    Thanks in advance to all who help.

  • SELECT

    Service

    ,CustomerName

    ,ConnectDate

    ,Disconnect

    FROM Table1

    EXCEPT

    SELECT

    Service

    ,CustomerName

    ,ConnectDate

    ,Disconnect

    FROM Table2

    SELECT

    Service

    ,CustomerName

    ,ConnectDate

    ,Disconnect

    FROM Table2

    EXCEPT

    SELECT

    Service

    ,CustomerName

    ,ConnectDate

    ,Disconnect

    FROM Table1

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

  • A thousand thanks - that worked perfectly ! Thanks so much !

  • You're welcome! 🙂

    ---------------------------------------------------------

    It takes a minimal capacity for rational thought to see that the corporate 'free press' is a structurally irrational and biased, and extremely violent, system of elite propaganda.
    David Edwards - Media lens[/url]

    Society has varying and conflicting interests; what is called objectivity is the disguise of one of these interests - that of neutrality. But neutrality is a fiction in an unneutral world. There are victims, there are executioners, and there are bystanders... and the 'objectivity' of the bystander calls for inaction while other heads fall.
    Howard Zinn

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

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