SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE

后端 未结 7 1695
轻奢々
轻奢々 2020-12-04 08:21

I have a SQL 2005 database with approx 250 tables.

I want to temporarily enable ON DELETE CASCADE to all of the Foreign Keys so that I can do a bulk delete easily.

相关标签:
7条回答
  • 2020-12-04 09:23

    A simple solution I found is to export the database to a single file, use the search function to replace all the NO ACTION to CASCADE, drop the database and import the edited file.

    Information changed on the database between the export and import will be lost.

    0 讨论(0)
提交回复
热议问题