Etienne
Etienne

Reputation: 7201

Return missing records from 1 SQL statement compare to another

The two statements are identical besides for the extra JOIN on statement A.

How can I return just the 110 records from the two T-SQL statements that are not in the result set of statement B?

Upvotes: 0

Views: 84

Answers (3)

Franklin
Franklin

Reputation: 905

Try to post same query or similer query as per your requirement then u will get right answer try the below one

select TBL1.c1.........TBL2.c1 ........... from TBL1 left join TBL2 on TBL1.pkcolumn=TB2.PKcolumn where TBL2.COLUMN is null

Upvotes: 0

Johann
Johann

Reputation: 1663

Can't be more specific without seeing your query, but this is the general idea:

SELECT 
  a.*
FROM 
( 
    --statement A
) a
LEFT OUTER JOIN 
(
    --statement B
) b 
  ON a.pk = b.pk
WHERE b.pk IS NULL

Upvotes: 2

Arsen Mkrtchyan
Arsen Mkrtchyan

Reputation: 50712

Do you mean EXCEPT or INTERSECT?

Upvotes: 3

Related Questions