As far as I know, you cannot rely on SQL Server dependency management. Lukas noted one of many questions.
In 2005, the equivalent of the old syscomments table is sys.sql_modules.
To find all table names that are not found in the TSQL code (views, SP, functions), use this operator:
select t.name, sys.objects.name foundin, sys.objects.type_desc from sys.objects t left outer join sys.sql_modules inner join sys.objects on sys.objects.object_id = sys.sql_modules.object_id on sys.sql_modules.definition like '%' + t.name + '%' where t.type = 'U' and sys.objects.name is null order by t.name, type_desc, foundin
If you comment out a line with the IS NULL condition, you will find all occurrences of all table names in the TSQL code. (regardless of whether the table name really refers to this table)
devio
source share