• I realise this is old, but I found it useful today.

    I modified the code: -

    ;WITH stored_procedures AS (

    SELECT

    o.name AS proc_name, oo.name AS table_name,

    ROW_NUMBER() OVER(partition by o.name,oo.name ORDER BY o.name,oo.name) AS row

    FROM sysdepends d

    INNER JOIN sysobjects o ON o.id=d.id

    INNER JOIN sysobjects oo ON oo.id=d.depid

    WHERE o.xtype = 'P')

    SELECT proc_name, table_name FROM stored_procedures

    WHERE row = 1

    ORDER BY proc_name,table_name

    This gets rid of the issue that some were having with duplicated table names.

    Also - please bear in mind that "o.xtype = 'P'" means I am only returning stored-procedures, nothing else.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/