Thursday, April 5, 2012

How To Find Not Matching Records From 2 Tables

Using except

select customerkey from Fact_OpenSalesOrdersHeader EXCEPT select customerkey from dim_customer

Using Join

SELECT a.customerkey FROM Fact_OpenSalesOrdersHeader a LEFT OUTER JOIN dim_customer b ON a.customerkey = b.customerkey WHERE b.customerkey IS NULL

Using Not In

select distinct customerkey from Fact_OpenSalesOrdersHeader where customerkey notin(select customerkey from dim_customer)

No comments: