参考:https://www.cnblogs.com/coce/p/8052574.html
1 DECLARE @sel_str NVARCHAR(20) = 'WAP_CONFIG2'; 2 WITH proc_temp AS ( 3 SELECT Pr_Name AS spName 4 FROM ( SELECT Pr.name AS Pr_Name , 5 parameter.name + ' ' + Type.name + ' (' 6 + CONVERT(VARCHAR(32), parameter.max_length) + ')' AS Parameter 7 FROM sys.procedures Pr 8 LEFT JOIN sys.parameters parameter ON Pr.object_id = parameter.object_id 9 INNER JOIN sys.types Type ON parameter.system_type_id = Type.system_type_id 10 WHERE type = 'P' 11 ) tb 12 WHERE Pr_Name NOT LIKE 'sp_%' --and Pr_Name not like 'dt%' 13 GROUP BY Pr_Name 14 ) 15 SELECT spName, (SELECT TOP 1 TEXT FROM syscomments WHERE id=object_id(spName) AND TEXT LIKE'%'+@sel_str+'%') AS sp_text INTO #temp_sp FROM proc_temp; 16 17 SELECT * FROM #temp_sp WHERE sp_text IS NOT NULL; 18 19 DROP TABLE #temp_sp;