How To Find Foreign Key Dependancies



TODO:

Have you ever wanted to find Foreign Key dependancies using T-SQL?

 

SOLUTION:

SELECT fk.name, OBJECT_NAME(fk.parent_object_id) as DepTable
FROM sys.foreign_keys fk
inner join sys.tables st on st.[object_id] = fk.referenced_object_id
WHERE st.name = 'MyTable'

NOTES:

No notes apply to this topic.



Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading