SQL Server中是否可以列出从特定对象加入的数据库中的所有视图?
即:从表myTable中找到所有联接的视图
您可以使用sys.sql_dependencies:
sys.sql_dependencies
select object_name(object_id),* from sys.sql_dependencies where referenced_major_id = object_id('<tablename>');
这将列出所有依赖于表的对象,您可以通过加入反对将其限制为视图sys.views:
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>');