How to get Referenced Table and Column Name in SQL Server.


Query to get Referenced Table, Referring Table, Foreign Key, Referenced Column, Referring Column

SELECT OBJECT_NAME (FK.referenced_object_id) 'Referenced Table', 
OBJECT_NAME(FK.parent_object_id) 'Referring Table', 
FK.name 'Foreign Key', 
COL_NAME(FK.referenced_object_id, FKC.referenced_column_id) 'Referenced Column',
COL_NAME(FK.parent_object_id,FKC.parent_column_id) 'Referring Column'
FROM sys.foreign_keys AS FK
    INNER JOIN sys.foreign_key_columns AS FKC 
        ON FKC.constraint_object_id = FK.OBJECT_ID
WHERE OBJECT_NAME (FK.referenced_object_id) = 'Table_Name'


Note : Table_Name is the table name