x002548's Blog

Not Just a Number - Brett Kaiser
posts - 89, comments - 586, trackbacks - 39

Friday, September 22, 2006

How do I find all the tables referenced by Stored Procedures or Functions

Like this

SELECT o.name, t.TABLE_NAME, c.text
  FROM syscomments c
  JOIN sysobjects o
    ON c.id = o.id
  JOIN INFORMATION_SCHEMA.Tables t
    ON  c.text LIKE '%'+t.TABLE_NAME+'%'

 

posted @ Friday, September 22, 2006 12:32 PM | Feedback (6) | Filed Under [ SQL Server ]

Powered by:
Powered By Subtext Powered By ASP.NET