March 8, 2018 at 9:03 am
Hello,
I have a hierarchy of tables in my database. They look like this:
--Reports
----ReportMetrics
----ReportTopN
----ReportComments
That is, a one-to-many relation exists between reports and ReportMetrics, ReportTopN, and ReportComments. Each of the three child tables have foreign key references to a particular report.
I'm wondering how to set cascading on deletes.
I know that I can set the delete rule on foreign keys to Cascade in SSMS. I did it like so for the Report foreign key in ReportComments:
I did the same for the other two foreign keys. Then I tried to delete a report and it told me I couldn't because of a foreign key constraint. Then I opened the Foreign Key Relationships dialog box again and found that the delete rule had been set back to No Action. So it seems I can't set the delete rule to Cascade.
How does one set cascading on delete in SQL?
March 8, 2018 at 9:11 am
See the details here:
https://stackoverflow.com/questions/6260688/how-do-i-use-cascade-delete-with-sql-server
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
March 8, 2018 at 2:55 pm
sgmunson - Thursday, March 8, 2018 9:10 AM
Excellent! That link has the answer I was looking for. Thanks!
March 9, 2018 at 10:16 am
junk.mail291276 - Thursday, March 8, 2018 2:55 PMsgmunson - Thursday, March 8, 2018 9:10 AMExcellent! That link has the answer I was looking for. Thanks!
Glad I could help.
Steve (aka sgmunson) 🙂 🙂 🙂
Rent Servers for Income (picks and shovels strategy)
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply