'How to delete parent and child records

I need to create an ad-hoc delete query in SQL Server to delete parent/child/grandchild records from 3 tables based on a certain date. However, there are no foreign key relationships defined in the database.

TableA keys on OrderID. TableB keys on OrderID and ProductID and has child records to TableA based on OrderID. TableC is keyed on OrderID, ProductID, ReleaseID and has child records to TableB based on OrderID and ProductID.

I want to delete records in all 3 tables based on an ExpirationDate in TableA. Is there a way to accomplish this with a single delete query with joins? Or, is this something better handled using a SP?

Thanks.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source