1 被我引用的对象
SELECT * FROM sys.dm_sql_referenced_entities('TableName','OBJECT');
–查看依赖项
2 引用我的对象
SELECT * FROM sys.dm_sql_referencing_entities('TableName','OBJECT');
3 存储过程、视图引用
select distinct object_name(id) from syscomments where id in
(select id from sysobjects where type ='P') and text like '%表名%'
4 查询某字段在那些表里使用
select [name] from [库名].[dbo].sysobjects where id in(select id from [库名].[dbo].syscolumns Where name='字段名')
本文介绍了四个SQL查询语句,用于检查数据库中表的引用关系、依赖关系,存储过程和视图的引用,以及字段在哪些表中的使用情况。这些技巧对于数据库管理和维护至关重要。
1544

被折叠的 条评论
为什么被折叠?



