Have you ever wanted to find something that was referenced in the body of a SQL query?
Maybe you need to know what queries you will have to modify for an upcoming table rename. Or maybe you want to see how many queries on your server are running SELECT *
Below are two templates you can use to search across the text of SQL queries on your server.
Click through for the scripts. Finding references in T-SQL objects (views, procedures, functions, triggers, etc.) is a fairly straightforward process. Finding references in ad hoc statements is much more hit-or-miss.