December 3, 2002 at 9:49 am
I have two identically structured tables, A and B. "A" has the correct records, "B" is like "A" but has some rows missing. The first column is a unique identifier key. How do I determine what the missing rows are? This is a pretty fundamental database activity but I can't figure out how to do it in SQL server. I can do an outer join on A & B, returning both NULL and regular rows, but there seems to be no way to see the unique identifier from table "A" that corresponds to a null in "B".
December 3, 2002 at 10:20 am
SELECT A.*
FROM A
LEFT OUTER JOIN B ON B.key = A.key
WHERE B.key IS NULL
will show all rows in A that do not have a corresponding key in B
Far away is close at hand in the images of elsewhere.
Anon.
December 3, 2002 at 10:23 am
Slight addition... I want to see JUST the rows that are missing... not all rows, NULL or not. So I would like to list the keys from "A" that correspond to the missing rows in "B".
December 3, 2002 at 10:31 am
The sql should do that. e.g. if A contains keys 1,2,3 and B contains 1,3 then the query will return 2 only.
Far away is close at hand in the images of elsewhere.
Anon.
December 3, 2002 at 11:57 am
It works great. Thanks!
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy