Use this script to get a list of tables that are referenced in a stored procedure. Just replace the value set for the variable "@sproc" to the name of the sproc you are evaluating:
|
declare @sproc varchar(8000)
set @sproc='spMyStoredProc'
CREATE TABLE #endchars (endchar char(1))
INSERT INTO #endchars (endchar)
select ' ' union select ')' union select ']' union select ';'
union select char(9) union select char(10) union select char(13)
select so.name
from sysobjects so, syscomments sc, #endchars ec
where so.type='U'
and object_name(sc.id)=@sproc
group by so.name
having sum(charindex(so.name+ec.endchar ,sc.text+' '))<>0
order by name
DROP TABLE #endchars
|
source: http://www.sqlservercentral.com/scripts/SQL+Server+2000/65162/