Saturday, January 19, 2008

Comparing Multiple Datasets with the INTERSECT and EXCEPT operators

A manual Diff tool for SQL 2005...

With SQL Server 2005, Microsoft introduced the INTERSECT and EXCEPT operators to further extend what you could already do with the UNION and UNION ALL operators.

  • INTERSECT - gives you the final result set where values in both of the tables match
  • EXCEPT - gives you the final result set where data exists in the first dataset and not in the second dataset

The advantage of these commands is that it allows you to get a distinct listing across all of the columns such as the UNION and UNION ALL operators do without having to do a group by or do a comparison of every single column.  

Source: Comparing Multiple Datasets with the INTERSECT and EXCEPT operators

No comments: