如何查找存储过程调用?
问题描述:
答
如果你需要按名称查找数据库对象(如表,列,触发器) - 看看所谓SQL Search的免费红门工具,它做到这一点 - 它搜索整个数据库的任何种类的字符串(S)。
因此,在您的情况下,如果您的知道您感兴趣的存储过程的调用 - 只需在搜索框中键入该关键字,SQL Search将快速向您显示该存储过程的所有位置叫从。
这是一个伟大的必须具备的任何DBA或数据库开发人员工具 - 为什么我已经提到它的绝对免费用于任何用途的?
答
您可以尝试在SQL Server Management Studio中使用View Dependencies
。
右键单击存储过程并选择View Dependencies
。但是我发现它并不总是100%准确。
答
您可以创建一个 '查找' SP
我用这一个数据库对象中搜索文本:
CREATE sp_grep (@object varchar(255))
as
SELECT distinct
'type' = case type
when 'FN' then 'Scalar function'
when 'IF' then 'Inlined table-function'
when 'P' then 'Stored procedure'
when 'TF' then 'Table function'
when 'TR' then 'Trigger'
when 'V' then 'View'
end,
o.[name],
watchword = @object
FROM dbo.sysobjects o (NOLOCK)
JOIN dbo.syscomments c (NOLOCK)
ON o.id = c.id
where c.text like '%'[email protected]+'%'
答
View the Dependencies of a Stored Procedure:
select *
from sys.dm_sql_referencing_entities('[SchemaName].[SPName]', 'OBJECT');
多少钱? =) – Yatrix 2012-04-16 16:21:23
@Yatrix:**没有** - zip,zilch,nada - niente - rien du tout - 足够清楚了吗? :-) – 2012-04-16 16:22:02
听起来很贵,但我可以负担得起。谢谢。 – Yatrix 2012-04-16 16:23:55