Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Deleting orphaned records

Author  Topic 

dcarva
Posting Yak Master

140 Posts

Posted - 2001-11-06 : 00:45:51
Hi,

I need an example of how to delete orphaned records. Let's say there is an Orders table and an OrderDetails table. Each entry in the Orders table has an entry in the OrderDetails table. (they are linked by orderid) How can I delete all entries in the OrderDetails table whose OrderId does not match any entry in the Orders table? Ex:

Orders OrderDetails
------ ------------
101 101
102 103
NULl 104

Your help is appreciated!
Thanks

   

- Advertisement -