CREATE PROCEDURE wit_DeleteCompany @CompanyKey int AS BEGIN -- If the company key does not exist in the clients table... IF NOT EXISTS(SELECT CompanyKey FROM wit_Clients WHERE CompanyKey = @CompanyKey) BEGIN -- Delete the address records DELETE FROM wit_Addresses WHERE AddressKey IN (SELECT AddressKey FROM wit_CompanyAddresses WHERE CompanyKey = @CompanyKey) -- Delete the CompanyAddress link table records DELETE FROM wit_CompanyAddresses WHERE CompanyKey = @CompanyKey -- Delete the company record DELETE FROM wit_CompanyInfo WHERE CompanyKey = @CompanyKey END ELSE RAISERROR('Company key is in use and cannot be deleted', 18, 0) ENDIt ensures that a company is not in use before deleting it.