Reputation: 815
I need to use SQL to identify all foreign keys that have a cascading delete. Can someone tell me where I can find out whether a foreign key is cascading?
Thanks!
Upvotes: 1
Views: 48
Reputation: 477
you can look in informatation_schema
select * from INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
where DELETE_RULE = 'CASCADE' OR UPDATE_RULE = 'CASCADE'
Upvotes: 1
Reputation: 280272
SELECT * FROM sys.foreign_keys
WHERE delete_referential_action > 0
OR update_referential_action > 0;
Upvotes: 3