Cascading Delete
-
I have an ms sql database that has foreign key relationships and until today I hadn't mapped those out via sql server, they were just on paper. So for example, I have a Company with many People. Before, when I deleted a Company, it's many people were orphaned. Now, since I've mapped the relationship for the sql server, when I try to delete a Company, I get an error. I think in mysql talk this is called a cascading delete. How do I do this with ms sql?
/\ |_ E X E GG
-
I have an ms sql database that has foreign key relationships and until today I hadn't mapped those out via sql server, they were just on paper. So for example, I have a Company with many People. Before, when I deleted a Company, it's many people were orphaned. Now, since I've mapped the relationship for the sql server, when I try to delete a Company, I get an error. I think in mysql talk this is called a cascading delete. How do I do this with ms sql?
/\ |_ E X E GG
Which database product are you using? With most databases you just need to add
ON DELETE CASCADE
to your foreign-key definition.If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".
-
Which database product are you using? With most databases you just need to add
ON DELETE CASCADE
to your foreign-key definition.If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message".