Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Where not exists

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2012-10-22 : 10:34:49
I have two identical tables.

bmp1 bmp2


bmp1
item_no comp_item
ABC XYZ


I want to select records that do not exist in bmp2

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-10-22 : 11:07:19
[code]SELECT * FROM bmp1
EXCEPT
SELECT * FROM bmp2;[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-10-22 : 12:21:31
[code]
SELECT *
FROM bmp1 b1
WHERE NOT EXISTS (SELECT 1 FROM bmp2 WHERE comp_item = b1.item_no)
[/code]

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -