Find All Rows in Table1 That Are Not in Table2 Using JOIN

tech — tags: — rohand @ February 15, 2010 1:06 PM

To find all rows that are in dbo.TABLE1 but not in dbo.TABLE2 using the SQL JOIN operator:

SELECT              COUNT(*)
FROM                dbo.TABLE1 t1 WITH (NOLOCK)
LEFT OUTER JOIN     dbo.TABLE2 t2 WITH (NOLOCK)
ON                  t1.PrimaryKey = t2.PrimaryKey
WHERE               t2.PrimaryKey IS NULL

0 Comments »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

©2012 appytizers. All rights reserved.