简体   繁体   English

如何找到存储过程调用?

[英]How can I find stored procedure calls?

Is there a way I can find where stored procedures are called in a SQL Server 2005 database? 有没有办法可以找到在SQL Server 2005数据库中调用存储过程的位置?

I tried using Find, but that doesn't work like it does in Visual Studios. 我尝试使用Find,但这不像在Visual Studios中那样工作。

Thanks in advance. 提前致谢。

If you need to find database objects (eg tables, columns, triggers) by name - have a look at the FREE Red-Gate tool called SQL Search which does this - it searches your entire database for any kind of string(s). 如果您需要按名称查找数据库对象(例如表,列,触发器) - 请查看名为SQL Search免费 Red-Gate工具,它会执行此操作 - 它会在整个数据库中搜索任何类型的字符串。

So in your case, if you know what the stored procedure is called that you're interested in - just key that into the search box and SQL Search will quickly show you all the places where that stored procedure is being called from. 因此,在您的情况下,如果您知道您感兴趣的存储过程是什么 - 只需将其键入搜索框,SQL搜索将快速显示调用该存储过程的所有位置。

在此输入图像描述

在此输入图像描述

It's a great must-have tool for any DBA or database developer - did I already mention it's absolutely FREE to use for any kind of use?? 对于任何DBA或数据库开发人员来说,它都是必备工具 - 我是否已经提到它可以完全免费用于任何类型的使用?

You can try using the View Dependencies in SQL Server Management Studio. 您可以尝试使用SQL Server Management Studio中的View Dependencies

Right-click on the stored procedure and select View Dependencies . 右键单击存储过程,然后选择“ View Dependencies However I have found it is not always 100% accurate. 但是我发现它并不总是100%准确。

You could create a 'find' SP 您可以创建一个“查找”SP

I use this one to search for the text in database objects: 我用这个来搜索数据库对象中的文本:

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 '%'+@object+'%' 

View the Dependencies of a Stored Procedure : 查看存储过程的依赖关系

select *
from sys.dm_sql_referencing_entities('[SchemaName].[SPName]', 'OBJECT');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM