Link to home
Start Free TrialLog in
Avatar of tommym121
tommym121Flag for Canada

asked on

SQL - the use of EXCEPT

I have a table 'Mytable' over 170k of records,  I have another table I called 'MytableLastUpdate'. I insert data to the 3rd table called MytableToBeUpdated by find the difference between Mytable and MytableLastUpdate. This is the query I used

Select * insert into MytableToBeUpdated  from Mytable Except Select * From MytableLastUpdate

All of them have the same schema. MytableLastUpdate is empty prior of running the query.

The result of the query indicate only 160 records is being inserted.

When I compare the two tables - Mytable and MytableToBeUpdated  with these two queries below
Select *   from Mytable Except Select * From MytableToBeUpdated
 Select *   from MytableToBeUpdated Except Select * From Mytable

The output is empty meaning no records are different and no extra records. What is going on here? Does it make sense to anyone at all?
SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of tommym121

ASKER

How do I find out if there are duplicate records if there is no keys for these table at all
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks