Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The stock answer is "sp_depends", but in SQL 7.0 and 2000 it was not guaranteed to be accurate (that is, up to date). I don't know if they've addressed this in SQL 2005 or 2008, as I rolled my own work-around quite some time ago. This doesn't do exaclty what you want, but it can get you there sooner than otherwise</p> <p>It's based on this query:</p> <pre><code>DECLARE @SearchText varchar(100) SET @SearchText = 'ProductId' SELECT schema_name(ob.schema_id) SchemaName ,ob.name ,ob.type_desc ,len(mo.definition) CodeLength ,mo.definition from sys.sql_modules mo inner join .sys.objects ob on ob.object_id = mo.object_id where mo.definition like '%' + @SearchText + '%' order by case schema_name(ob.schema_id) when 'dbo' then 'A' else 'B' + str(ob.schema_id, 10) end ,ob.type_desc ,ob.name </code></pre> <p>This will search through all the text-type database objects stored in sys.objects that have data/definitions in sys.modules. This covers stored procedures, functions, and views, and might also covers triggers and some constraints (I don't know one way or the other). It does not track synonyms, their definitions are stored in their own system table.</p> <p>The results will return a list of all such objects that contain the specified string. It in no way tries to evaluate the context in which the string appears--if it's a table, column, variable, or comment, it's a hit and gets included. This means your mileage will vary depending on how unique the string your searching for is... but on the flip side, you can look for more than just columns with this.</p> <p>Returned columns are:</p> <ul> <li>SchemaName</li> <li>Name (of object containing the string)</li> <li>type_desc (as from sys.objects)</li> <li>CodeLength (how big is the chunk o' code the string was found in)</li> <li>definition (a copy of said chunk of code. Hmm, I never use this, maybe I should take it out?)</li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload