Monday, 18 August 2025

Below query will get the table FK reference table list.

 Below query  will get the table FK reference table list. 

DECLARE @InputTableName NVARCHAR(128) = 'company_master';

 SELECT DISTINCT 

    OBJECT_NAME(fk.referenced_object_id) AS referenced_table
FROM sys.foreign_keys fk
WHERE OBJECT_NAME(fk.parent_object_id) = @InputTableName
  AND OBJECT_NAME(fk.referenced_object_id) IS NOT NULL
ORDER BY referenced_table;

 

 

No comments:

Post a Comment

SQLDBA - Get Space Used by Tables and Indexes in SQL Server

 Get Space Used by Tables and Indexes in SQL Server Databases can consume significant amounts of storage, so it’s important to understand ho...