检查 SQL 对象是否被任何其他 SQL 对象引用 [英] Check if SQL object is referenced by any other SQL objects
问题描述
我只是在阅读 this SO thread 并且向@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.
这可能吗,如果可以,怎么办?
Is this possible, if so how?
我会将此作为评论发布,但我还没有足够的声誉......
I would have posted this as a comment, but I don't have sufficient reputation yet...
推荐答案
可以,但不是用DMV,而是需要相关的动态管理function(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屋!