天天看点

如何查看一个数据表被哪些存储过程,视图,触发器,函数使用呢?

由于今天刚接收一个新系统的维护,

今天突然接到一个需求,查看一下这张表的数据来源,那么我们该如何开始此项工作呢?

下文笔者讲述,首先我们需查找数据表被哪些sql脚本使用,然后再进行下一步处理

--1.查询某个表被哪些存储过程使用到 :
select distinct object_name(id)
from syscomments
where id in (select object_id from sys.objects where type ='P')
and text like'%TableName%'
 
  
--2.查找那些过程对该表做了更新操作:
select distinct object_name(id)
from syscomments
where id in(select object_id from sys.objects where type ='P')
and text like'%update tablename%'      

继续阅读