某些数据库对象的 SQL Server 2005 搜索视图 [英] SQL Server 2005 search views for certain database objects
本文介绍了某些数据库对象的 SQL Server 2005 搜索视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 SQL Server 中有没有办法列出数据库中从特定对象连接的所有视图?
Is there a way in SQL Server to list all the views within a database that join from a particular object?
ie: 从表 myTable 中查找所有加入的视图
ie: find all the views that join from the table myTable
推荐答案
您可以使用 sys.sql_dependencies
:
You can use sys.sql_dependencies
:
select object_name(object_id),*
from sys.sql_dependencies
where referenced_major_id = object_id('<tablename>');
这将列出依赖于您的表的所有对象,您可以通过加入反对 sys.views
:
This will list all objects that depend on your table, you can restrict this to views by joining against sys.views
:
select v.*
from sys.sql_dependencies d
join sys.views v on d.object_id = v.object_id
where referenced_major_id = object_id('<tablename>');
这篇关于某些数据库对象的 SQL Server 2005 搜索视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文