Answer the question
In order to leave comments, you need to log in
How to set all relationships in the database to cascade delete?
Hello, there is a large database with many links, but all these links have cascading deletion disabled, I need to delete certain data in several tables, but their links lead to other tables, and those to others.
It seems to me that the easiest way would be to write a script that will set a cascade delete for all links, then delete the data I need, and then return the link settings back.
Please tell me how can this be done?
I use mssql server and ms sql management studio
PS Thank you all!
Answer the question
In order to leave comments, you need to log in
Not all cascading deletes are allowed.
If cascading deletions were not defined at design time, an update and deletion specification would have to be defined for each link that interferes with the deletion.
In addition to deleting by link, there can be zeroing ( NULL
) or setting the default value. This may be required by the physical model.
It is better not to delete "dirty" data automatically, as "clean" ones may suffer. You can delete rows in tables by links ( JOIN
) separately.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question