Reputation: 676
For example, let's say that I have this 3 tables :
Table Customers:
CustomerID
Table Addresses:
AddressId
Table Customers_Addresses
CustomerID
AddressID
On SQL Server Management Studio, for the two FK I put "Delete Rule" and "Update Rule" to "Cascade".
So, when i delete a customer, all rows in "Customers_Addresses" that reference the CustomerID are deleted. Now, if I want that SQL Server 2008 also delete all rows in the "Addresses" table that are related to the customer i just deleted, what can i do ?
I read that i can load all related "Addresses" in my Customer object and call "DeleteObject" for all instances of Addresses. I'm not satisfied of this solution, i prefer a solution on SQL Server 2008, if it exists.
Thanks !
Upvotes: 1
Views: 931