Query to pull up all the Stored Procedures using a particular table

Last post 10-06-2008 5:34 AM by Varsha. 6 replies.
Page 1 of 1 (7 items)
Active Topics My Discussions Unanswered Sort Posts: Previous Next
  • 10-01-2008 2:00 AM

    Query to pull up all the Stored Procedures using a particular table

    I need a query which will return all the stored procedure which has a particular table called in it. For eg we have table called PRBuild_DealAll_DT and we need to know which all stored procs are calling this table.

  • 10-01-2008 3:03 AM In reply to

    Re: Query to pull up all the Stored Procedures using a particular table

    select object_name(m.object_id) as proc_name from sys.sql_modules as m inner join sys.procedures as p
    on m.object_id=p.object_id where object_name(m.object_id)='PRBuild_DealAll_DT'

    Madhivanan

    Failing to plan is Planning to fail
  • 10-01-2008 7:12 AM In reply to

    Re: Query to pull up all the Stored Procedures using a particular table

     Also

    from management studio , you can view dependency of the table

    - objects that depends on <mytable>
    - objects on which <mytable> depends

     

    MCSE , MCITP (SQL 2005 Administration & Development), MCTS, MCPD
  • 10-02-2008 10:23 PM In reply to

    Re: Query to pull up all the Stored Procedures using a particular table

    Thanks for responding!! But when I tried running the above query it did not return any procedure name which is not possible because i am sure that there are few procedures which are calling this table.

  • 10-03-2008 11:31 AM In reply to

    Re: Query to pull up all the Stored Procedures using a particular table

    if the name of table within dynamic sql statement in the stored procedure , you can't  get  any dependency.

    bz, when you try to create sp , while compiling ,sql server  check dependency except for dynamic sql.

    MCSE , MCITP (SQL 2005 Administration & Development), MCTS, MCPD
  • 10-03-2008 1:03 PM In reply to

    • satya
    • Top 10 Contributor
    • Joined on 11-05-2002
    • United Kingdom
    • Posts 22,515
    • Microsoft MVP
      Moderator

    Re: Query to pull up all the Stored Procedures using a particular table

    Try:

    SELECT DISTINCT o.name ,o.xtype
        
    FROM 
    syscomments c
                
    INNER JOIN sysobjects o ON c.id=
    o.id
        
    WHERE c.TEXT LIKE '%tablename%'

    -Satya S K J

    SQL Server MVP



    Knowledge is Power, you will gain by sharing it. SSQA.net - Invisible contributions to the users & visible success in SQL Community.
  • 10-06-2008 5:34 AM In reply to

    Re: Query to pull up all the Stored Procedures using a particular table

    Thanks a lot this was helpful..

Page 1 of 1 (7 items)
Active Topics   My Discussions    Unanswered Posts


© 2000 - 2007 vDerivatives Limited All Rights Reserved.