【发布时间】:2012-04-16 16:12:40
【问题描述】:
有没有一种方法可以找到在 SQL Server 2005 数据库中调用存储过程的位置?
我尝试使用 Find,但它不像在 Visual Studios 中那样工作。
提前致谢。
【问题讨论】:
标签: sql sql-server-2005 stored-procedures
有没有一种方法可以找到在 SQL Server 2005 数据库中调用存储过程的位置?
我尝试使用 Find,但它不像在 Visual Studios 中那样工作。
提前致谢。
【问题讨论】:
标签: sql sql-server-2005 stored-procedures
如果您需要按名称查找数据库对象(例如表、列、触发器) - 请查看名为 SQL Search 的 FREE Red-Gate 工具,它会搜索您的整个任何类型字符串的数据库。
因此,在您的情况下,如果您知道您感兴趣的存储过程称为什么 - 只需将其键入搜索框,SQL 搜索就会快速向您显示该存储过程的所有位置正在调用存储过程。
对于任何 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 '%'+@object+'%'
【讨论】:
View the Dependencies of a Stored Procedure:
select *
from sys.dm_sql_referencing_entities('[SchemaName].[SPName]', 'OBJECT');
【讨论】: