Foreign Key with Action

/ Published in: SQL
Save to your folder(s)

Foreign Key with actions on delete or update.

Copy this code and paste it in your HTML
  1. SELECT AS foreign_key_name ,
  2. OBJECT_NAME(f.parent_object_id) AS TABLE_NAME ,
  3. COL_NAME(fc.parent_object_id, fc.parent_column_id) AS constraint_column_name ,
  4. OBJECT_NAME(f.referenced_object_id) AS referenced_object ,
  5. COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS referenced_column_name ,
  6. delete_referential_action_desc ,
  7. update_referential_action_desc
  8. FROM sys.foreign_keys AS f
  9. INNER JOIN sys.foreign_key_columns AS fc ON f.object_id = fc.constraint_object_id
  10. WHERE (delete_referential_action_desc <> 'NO_ACTION'
  11. OR update_referential_action_desc <> 'NO_ACTION') AND is_disabled=0

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.