Subject | How do I return a set containing all records without a entry in the parent table. |
---|---|
Author | Adrian Wreyford |
Post date | 2008-11-28T19:26:19Z |
Hi.
I have some sloppy code that allowed for the situation to exist, where a parent record could be deleted, without a foreign key cascade delete of the child records.
Now I need to find all these records, and delete them manually before I can set up the foreign key constraint.
I tried:
Select AssistDetails.ASSISTENTRYID From AssistDetails
Where AssistDetails.ASSISTENTRYID Not In(Select Entry2.ENTRYID From Entry2)
but it just hangs indefinitely.
Entry2 is the master table, with the Assistdetails the child table.
I need all AssistEntryID's with no corresponding entries in Entry2.EntryID.
Thanks
Adrian
[Non-text portions of this message have been removed]
I have some sloppy code that allowed for the situation to exist, where a parent record could be deleted, without a foreign key cascade delete of the child records.
Now I need to find all these records, and delete them manually before I can set up the foreign key constraint.
I tried:
Select AssistDetails.ASSISTENTRYID From AssistDetails
Where AssistDetails.ASSISTENTRYID Not In(Select Entry2.ENTRYID From Entry2)
but it just hangs indefinitely.
Entry2 is the master table, with the Assistdetails the child table.
I need all AssistEntryID's with no corresponding entries in Entry2.EntryID.
Thanks
Adrian
[Non-text portions of this message have been removed]