检查其他任何SQL对象是否引用了SQL对象 [英] Check if SQL object is referenced by any other SQL objects
问题描述
我只是在阅读这个SO线程,并向@Mack询问是否有一种方法可以检查某个SQL对象是否被其他任何SQL对象引用.
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.
他(@Mack)使用T-SQL和DMV完成了类似的回答.
He (@Mack) used T-SQL and DMVs to accomplish something similar in his answer.
有可能吗?
本来可以将此作为评论发布,但是我还没有足够的声誉...
I would have posted this as a comment, but I don't have sufficient reputation yet...
推荐答案
您可以,但不能使用DMV,而是需要相关的动态管理功能(DMF)dm_sql_referencing_entities
(更多信息此处).
You can, but not with a DMV instead you'll need a related dynamic management function(DMF) dm_sql_referencing_entities
(more info here).
这是代码:
SELECT referencing_schema_name
, referencing_entity_name
FROM sys.dm_sql_referencing_entities ('*schemaname.objectname*', 'OBJECT');
这是DMV和DMF上的链接到MSDN页面.
Here's a link to the MSDN page on DMVs and DMFs.
这篇关于检查其他任何SQL对象是否引用了SQL对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!