I need to delete all the children, grandchildren, etc. for a specific company id. The parent table has over 100 children with some of the children having more than one foreign key to the parent. We do not have ON DELETE CASCADE on the constraints. Does anyone have a script that will generate the appropriate delete statements in the correct order or a script that will alter the constraint so it will have the ON DELETE CASCADE. This is a test system that I need to clear out all rows for this company as soon as possible so they can copy it over from production and test a new configuration for the customer without changing any of the other test customer data.
Any help would be greatly appreciated.