【问题标题】:How can I find stored procedure calls?如何找到存储过程调用?
【发布时间】:2012-04-16 16:12:40
【问题描述】:

有没有一种方法可以找到在 SQL Server 2005 数据库中调用存储过程的位置?

我尝试使用 Find,但它不像在 Visual Studios 中那样工作。

提前致谢。

【问题讨论】:

    标签: sql sql-server-2005 stored-procedures


    【解决方案1】:

    如果您需要按名称查找数据库对象(例如表、列、触发器) - 请查看名为 SQL SearchFREE Red-Gate 工具,它会搜索您的整个任何类型字符串的数据库。

    因此,在您的情况下,如果您知道您感兴趣的存储过程称为什么 - 只需将其键入搜索框,SQL 搜索就会快速向您显示该存储过程的所有位置正在调用存储过程。

    对于任何 DBA 或数据库开发人员来说,它都是必备工具 - 我是否已经提到它绝对免费可用于任何用途??

    【讨论】:

    • @Yatrix: nothing - zip, zilch, nada - niente - rien du tout - 够清楚吗? :-)
    • 听起来很贵,但我买得起。谢谢。
    • 这只是它的声音——它确实很快就收回了成本——说真的! :-)
    • 很好,我完全忘记了红门。
    【解决方案2】:

    您可以尝试在 SQL Server Management Studio 中使用View Dependencies

    右键单击存储过程并选择View Dependencies。但是我发现它并不总是 100% 准确。

    【讨论】:

      【解决方案3】:

      您可以创建一个“查找”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+'%' 
      

      【讨论】:

        【解决方案4】:

        View the Dependencies of a Stored Procedure:

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

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2010-10-25
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多