SQL - the use of EXCEPT
Posted on 2012-09-14
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?