sql: check if entry in table A exists in table B
SELECT *
FROM B
WHERE NOT EXISTS (SELECT 1
FROM A
WHERE A.ID = B.ID)
The classical answer that works in almost every environment is
SELECT ID, Name, blah, blah
FROM TableB TB
LEFT JOIN TableA TA
ON TB.ID=TA.ID
WHERE TA.ID IS NULL
sometimes NOT EXISTS may be not implemented (not working).
If you are set on using EXISTS you can use the below in SQL Server:
SELECT * FROM TableB as b
WHERE NOT EXISTS
(
SELECT * FROM TableA as a
WHERE b.id = a.id
)