krot

sql server просмотр внешних ключей

Mar 7th, 2018
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. USE AdventureWorks2012;  
  2. GO  
  3. SELECT  
  4.     f.name AS foreign_key_name  
  5.    ,OBJECT_NAME(f.parent_object_id) AS table_name  
  6.    ,COL_NAME(fc.parent_object_id, fc.parent_column_id) AS constraint_column_name  
  7.    ,OBJECT_NAME (f.referenced_object_id) AS referenced_object  
  8.    ,COL_NAME(fc.referenced_object_id, fc.referenced_column_id) AS referenced_column_name  
  9.    ,is_disabled  
  10.    ,delete_referential_action_desc  
  11.    ,update_referential_action_desc  
  12. FROM sys.foreign_keys AS f  
  13. INNER JOIN sys.foreign_key_columns AS fc  
  14.    ON f.object_id = fc.constraint_object_id  
  15. WHERE f.parent_object_id = OBJECT_ID('HumanResources.Employee');
RAW Paste Data