Check if SQL object is referenced by any other SQL objects

前端 未结 1 896
礼貌的吻别
礼貌的吻别 2021-01-26 02:11

I was just reading this SO thread and had a question for @Mack regarding whether there is a way to check if a SQL object is referenced by any other SQL objects.

He (@Mac

相关标签:
1条回答
  • 2021-01-26 02:33

    You can, but not with a DMV instead you'll need a related dynamic management function(DMF) dm_sql_referencing_entities (more info here).

    Here is the code:

    SELECT referencing_schema_name
         , referencing_entity_name
    FROM sys.dm_sql_referencing_entities ('*schemaname.objectname*', 'OBJECT');
    

    Here's a link to the MSDN page on DMVs and DMFs.

    0 讨论(0)
提交回复
热议问题