Use 数据库 DECLARE@ProcNamevarchar(50) CreateTable #tmpName(Content varchar(2000)) CreateTable #tmp(ProcName varchar(2000),Content1 varchar(8000)) --定义一个游标 DECLARE SearchProc CURSORFOR --查询数据库中存储过程的名称,尽量去除系统PROC,可以根据crdate时间字段来寻找非系统PROC select name from sysobjects where type='P'and name notlike'dt_%' OPEN SearchProc FETCHNEXTFROM SearchProc INTO@ProcName WHILE@@FETCH_STATUS>=0 BEGIN Print@ProcName InsertInto #tmpName(Content) Exec sp_helptext @ProcName InsertInto #tmp(ProcName,Content1) select@ProcName,#tmpName.Content from #tmpName --填充完就清空一下临时表 Truncatetable #tmpName FETCHNEXTFROM SearchProc INTO@ProcName END CLOSE SearchProc DEALLOCATE SearchProc GO select ProcName from #tmp where Content1 like'%查找内容%'groupby ProcName select ProcName,Content1 from #tmp where Content1 like'%查找内容%' select ProcName,Content1 from #tmp where procname='存储过程名称' --删除临时表 DropTable #tmpName DropTable #tmp