SQL Server 2005 - Find Which Stored Procs Run To A Particular Table

后端 未结 2 513
心在旅途
心在旅途 2021-01-14 00:20
  • Is there a quick way that I can find which stored procedures run to a particular table in my database?
  • The database is very large with lots of tables and SPRO
2条回答
  •  心在旅途
    2021-01-14 01:18

    If you want to restrict the search to stored procedures then you can do this:

    SELECT name
    FROM sys.objects
    WHERE type = 'P'
        AND OBJECT_DEFINITION(object_id) LIKE '%name_of_your_table%'
    ORDER BY name
    

    If you wanted to include other SQL modules -- for examples, functions, triggers, views etc -- then you could alter the query to do WHERE type IN ('P', 'FN', 'IF', 'TF', 'V') etc, or use the alternative given in Martin's answer.

提交回复
热议问题