How to get only the non-matching entries from an outer join
From: Matt Hughes <mhughes_at_nospam.eeek>
Date: Wed, 20 Nov 2002 13:29:06 -0600
Message-ID: <5oRC9.28$tJ6.84589_at_news.uswest.net>
This comes up all the time. I'm trying to add a foreign key that wasn't previously modelled, but there are records that don't have their foreign keys in place yet for whatever reason. Usually a parent was dropped and without the FK modelled it couldn't cascade leaving the orphaned records.
Date: Wed, 20 Nov 2002 13:29:06 -0600
Message-ID: <5oRC9.28$tJ6.84589_at_news.uswest.net>
This comes up all the time. I'm trying to add a foreign key that wasn't previously modelled, but there are records that don't have their foreign keys in place yet for whatever reason. Usually a parent was dropped and without the FK modelled it couldn't cascade leaving the orphaned records.
I end up finding these by doing an outer join to a temp table, and then iterating through the temp table looking for NULLs and reporting on them, or clearing out the "bad" records.
There ought to be a better way to do this, but for the life of me, I can't think of it. I'm worried this is one of those questions with an obvious
answer, but it just hasn't popped into my mind.Thanks in advance for any help!
-- MattReceived on Wed Nov 20 2002 - 20:29:06 CET