SQLUSA

Microsoft SQL Server 2005
Database Design Best Practices

How to data compare two tables using EXCEPT?

 

Execute the following script in Query Editor to demonstrate the data compare of two identical tables using the EXCEPT operator. If both EXCEPT queries return empty result sets, the two tables are identical.

use tempdb;

go

 

select * into dbo.ProductInventory

from AdventureWorks.Production.ProductInventory

go

 

select * from dbo.ProductInventory

except

select * from AdventureWorks.Production.ProductInventory

go

 

 

select * from AdventureWorks.Production.ProductInventory

except

select * from dbo.ProductInventory

go


 

The Best SQL Server 2005 Training in the World
 
 
SQLUSA.com Home Page