• It took me a minute to work out a query that would tell me the specific tables AND FIELDS that are used in a stored procedure. I am trying to build requirements for our data warehouse and don't necessarily need to bring over every field in every table. This works great for me (I'm using 2012), with one exception noted below.

    SELECT DISTINCT

    O.name SP_Name,T.name Table_Name,c.name Field_Name

    FROM sys.sysdepends D

    JOIN sys.sysobjects O ON O.id = D.id

    JOIN sys.sysobjects T ON T.id = D.depid

    JOIN sys.columns C ON C.column_id=d.depnumber

    and C.object_id=D.depID

    WHERE O.xtype = 'P'

    and o.name = 'sp_yourstoredprocedure'

    The only time this hasn't worked for me is when the stored procedure was built into a #temp table first with results returning from the #temp table. Those are poor code and need to be re-written anyway. :/