SigmundFraud
asked on
Tracking what tables appear in which queries
Hi
I have tables A,B,C that need to be renamed. However they are referenced in several queries and i would need some code that would list what queries these tables appear in.
Many thanks!
I have tables A,B,C that need to be renamed. However they are referenced in several queries and i would need some code that would list what queries these tables appear in.
Many thanks!
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Tables can be referenced directly by program code. It's hard to know what queries can be run by the various programs that connect to your database. However, if you only refer to Stored Procedures, Functions, and Views, then
select distinct object_name(id) from syscomments where text like '%tbl%'
order by 1
select distinct object_name(id) from syscomments where text like '%tbl%'
order by 1
It's possible that procedures are created encrypted, so this technique will not work. In that case, you will need to find a decrypter (sql2000 ones are easily found) and actually decrypt each and every proc and drop/create them unencrypted before syscomments will reveal anything useful.
views should be accesible using the code as well. we are referencing the sysobjects table
ASKER
Excellent solution, thanks Witty.
ASKER
They're in some sp's but mainly in views.