With SQL Deleter, you quickly get all relationships that needs to be updated when executing an SQL query

For this example we use the free test database from Microsoft AdventureWorks2022

I send it to SQL Deleter the following query:

delete from [Person].[Person] where BusinessEntityID = 1;

SQL Deleter then returns:

DECLARE @PersonPersonBusinessEntityID TABLE (Id int);
DECLARE @HumanResourcesEmployeeBusinessEntityID TABLE (Id int);
DECLARE @PurchasingPurchaseOrderHeaderPurchaseOrderID TABLE (Id int);
DECLARE @ProductionDocumentDocumentNode TABLE (Id hierarchyid);
DECLARE @SalesSalesPersonBusinessEntityID TABLE (Id int);

INSERT INTO @PersonPersonBusinessEntityID select [BusinessEntityID] from [Person].[Person] where BusinessEntityID = 1;
INSERT INTO @HumanResourcesEmployeeBusinessEntityID select [BusinessEntityID] from [HumanResources].[Employee] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
INSERT INTO @SalesSalesPersonBusinessEntityID select [BusinessEntityID] from [Sales].[SalesPerson] where [BusinessEntityID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
INSERT INTO @ProductionDocumentDocumentNode select [DocumentNode] from [Production].[Document] where [Owner] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
INSERT INTO @PurchasingPurchaseOrderHeaderPurchaseOrderID select [PurchaseOrderID] from [Purchasing].[PurchaseOrderHeader] where [EmployeeID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);

update [HumanResources].[JobCandidate] set [BusinessEntityID]=NULL where [BusinessEntityID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
update [Sales].[SalesOrderHeader] set [SalesPersonID]=NULL where [SalesPersonID] in (select Id from @SalesSalesPersonBusinessEntityID);
update [Sales].[Store] set [SalesPersonID]=NULL where [SalesPersonID] in (select Id from @SalesSalesPersonBusinessEntityID);
update [Person].[Test] set [PersonBusinessEntityID]=NULL where [PersonBusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
update [Sales].[Customer] set [PersonID]=NULL where [PersonID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Sales].[PersonCreditCard] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Person].[PersonPhone] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Person].[BusinessEntityContact] where [PersonID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Person].[EmailAddress] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Purchasing].[PurchaseOrderDetail] where [PurchaseOrderID] in (select Id from @PurchasingPurchaseOrderHeaderPurchaseOrderID);
delete from [Purchasing].[PurchaseOrderHeader] where [EmployeeID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
delete from [Production].[ProductDocument] where [DocumentNode] in (select Id from @ProductionDocumentDocumentNode);
delete from [Production].[Document] where [Owner] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
delete from [HumanResources].[EmployeeDepartmentHistory] where [BusinessEntityID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
delete from [HumanResources].[EmployeePayHistory] where [BusinessEntityID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
delete from [Sales].[SalesTerritoryHistory] where [BusinessEntityID] in (select Id from @SalesSalesPersonBusinessEntityID);
delete from [Sales].[SalesPersonQuotaHistory] where [BusinessEntityID] in (select Id from @SalesSalesPersonBusinessEntityID);
delete from [Sales].[SalesPerson] where [BusinessEntityID] in (select Id from @HumanResourcesEmployeeBusinessEntityID);
delete from [HumanResources].[Employee] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Person].[Password] where [BusinessEntityID] in (select Id from @PersonPersonBusinessEntityID);
delete from [Person].[Person] where BusinessEntityID = 1;

What normally might even take an hours, will not be generated instantly.