Compare two tables record (SQL Server)
Sometime we want to compare the records between two database tables. These databases could be on same server or on different servers. Here is some information about how we can compare records between two tables. Hope this will help and give you some information.
The ‘EXCEPT’ operator performs the compare between two tables:
When both databases are on same server:
The following query returns any distinct values from the query to the left of the EXCEPT operand that are not also found on the right query.
SELECT ProductID
FROM Production.Product
EXCEPT
SELECT ProductID
FROM Production.WorkOrder ;
–Result: 266 Rows (products without work orders)
