Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sql server, cascade delete and parent/child table

i have one simple table with following columns: id, name and parentID

i created relationship diagram between id and parentID (on a same table), like simple tree, on the same table, but when i tried to user cascade delete it was disabled for me

i know that it will be recursive delete if i will delete parent it will delete his children

have i any options for anable cascade delete without triggers?

like image 623
Sasha Avatar asked Sep 16 '09 15:09

Sasha


2 Answers

No, SQL Server does not allow recursive and/or multiple cascade paths.

You can use a stored procedure to delete bit by bit, or use a trigger. Sorry.

like image 79
gbn Avatar answered Sep 20 '22 18:09

gbn


best to use an after trigger for multiple actions.

like image 26
Jubal Avatar answered Sep 17 '22 18:09

Jubal