当我们对数据表进行修改时,比如删除某个字段。我们必须保证所有用到该字段的存储过程都必须做相应的修改。因此我们如果能用一条SQL语句来查找出所有包含该字段名称的存储过程,那将是非常方便的:
--查找包含某关键字的存储过程名
select
OBJECT_NAME
(id),id
from
syscomments
where id in
(
select
object_id (name)
from dbo.sysobjects
where xtype = ' P '
)
and text like ' %FieldName% '
where id in
(
select
object_id (name)
from dbo.sysobjects
where xtype = ' P '
)
and text like ' %FieldName% '
group by id