是否有任何存储过程或查询在特定字符串的所有数据库(也就是其他过程)中进行搜索?
我想在所有存储过程的代码中搜索单词Raiserror
,并且我只有字符串来解决该反射错误的原因。
谢谢你
答案 0 :(得分:3)
我使用RedGate SQL搜索在存储过程中查找文本。它是免费的,并安装在Management Studio中。
答案 1 :(得分:2)
这将找到包含文本的存储过程,视图,函数和触发器......
DECLARE @SearchString nvarchar(max)
SET @SearchString = 'Raiserror' --Text You Want To Find
SELECT DISTINCT
[SysObjects].[name] AS [Object Name],
[SysObjects].[type_desc] AS [Object Type]
FROM
[sys].[sql_modules] AS [SysMods]
LEFT OUTER JOIN [sys].[objects] AS [SysObjects] ON [SysMods].[object_id] = [SysObjects].[object_id]
WHERE
[SysMods].[definition] LIKE '%' + @SearchString + '%'
/*
--comment this in to only fined stored procedures
AND
[SysObjects].[type_desc] = 'SQL_STORED_PROCEDURE'
*/
ORDER BY
[SysObjects].[type_desc] ASC,
[SysObjects].[name] ASC