Link to home
Start Free TrialLog in
Avatar of F-J-K
F-J-KFlag for Canada

asked on

How to Delete Parent Record if Child Record is Deleted - MS SQL Server

I have two tables:

Customer
Phone

Customer has PhoneID as foreign key which points to PhoneID pk in Phone table.

If a customer record is deleted, i want the associate phone record in phone table to be deleted also. Obviously, i can not use ON DELETE CASCADE because in my case, i'm cascading deletion in reverse manner.

Any idea what to do?
ASKER CERTIFIED SOLUTION
Avatar of halfbloodprince
halfbloodprince

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

Thanks. I will give it a try, by the way, i'm trying to set it systematic/automatic.
Avatar of F-J-K

ASKER

In short, i want to delete a parent record if a child record is deleted. ON DELETE CASCADE only works for the opposite way.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of F-J-K

ASKER

Thanks