如何在给定数据库的所有存储过程中全局搜索关键字?
我使用了以下内容,但无法获得预期的结果…
SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = 'loadStatus' COLLATE SQL_Latin1_General_CP1_CI_AS ) SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name like '%loadStatus%' COLLATE SQL_Latin1_General_CP1_CI_AS )
问候-Vas
看一下此链接-http: //www.sqlservercentral.com/scripts/T-SQL+Aids/31131/,看看是否有帮助。
链接文章中的SP由Prasad Bhogadi编写,内容如下:
CREATE PROCEDURE SEARCHFORSTRING @SEARCHSTRING VARCHAR(100) AS SELECT DISTINCT(sysobjects.name) FROM sysobjects,syscomments WHERE sysobjects.id = syscomments.id AND sysobjects.type = 'P' AND sysobjects.category=0 AND CHARINDEX(@SEARCHSTRING ,syscomments.text)>0
您可以使用它在数据库中创建一个SP或使其适应一次查询。