CREATE VIEW TableReferences AS SELECT TOP 100 PERCENT t.TABLE_NAME, OBJECT_NAME(c.id) AS [OBJECT_NAME], COUNT(*) [MATCHES] FROM INFORMATION_SCHEMA.TABLES t, syscomments c WHERE t.TABLE_TYPE = 'BASE TABLE' AND c.text LIKE '%' + t.TABLE_NAME + '%' GROUP BY t.TABLE_NAME, c.id ORDER BY t.TABLE_NAME, [MATCHES] DESCGOSample Usage: SELECT * FROM TableReferences WHERE TABLE_NAME = 'MyTable'
Edited by - onamuji on 02/21/2002 16:13:27