1

I have a large database and I didn't add cascade on update/delete.

Can we do it with T-SQL without deleting and then recreating all the FK objects?

jpw
  • 44,361
  • 6
  • 66
  • 86
  • Maybe this answer can help you: [SQL Script to alter ALL Foreign Keys to add ON DELETE CASCADE](http://stackoverflow.com/a/871124/1175077) – jpw Feb 24 '14 at 17:26

1 Answers1

0

You should drop and recreate foreign keys. this is the only way. but you can use sys.foreign_keys and sys.foreign_key_columns to get the FK name and columns. then you can write a loop to fetch names and columns and drop an recreate it with cascade option in every time loop executed.

Amir Keshavarz
  • 3,050
  • 1
  • 19
  • 26