select distinct name
from sysobjects o, syscomments s
where o.id = s.id
and text like '%m_mrp_srm_base_His%'
and o.xtype = 'P'select OBJECT_NAME(id) as 存储过程,id from syscomments
where id in
(
select
object_id(name)
from dbo.sysobjects
where xtype='P' --存储过程为P
)
and text like '%TEST%' --关键字
group by id--查询表在哪个数据库中
SELECT t.name AS TableName,DB_NAME() AS DatabaseName
FROM sys.tables t
WHERE t.name = 'Table_Name';
--检查所有表是否包含某字段SELECT t.name AS TableName, c.name AS ColumnName
FROM sys.columns c
JOIN sys.tables t ON c.object_id = t.object_id
WHERE t.name IN (SELECT name FROM sys.tables) AND c.name like '%REL_DATE%';