title: SQL Server 2008 - Finding Specific Commands/Calls/Text
body: <p>I need to find an insert statement into a specific table.  Unfortunately, the application isn't mine to begin with, there are over 100 stored procedures in the database, I've stepped through the code writing down every stored procedure name from begining to end of this process and I still cannot find it.  I know that the process has to occur some where because another process that depends on it works properly. I just cant find it.</p>
  
  <p>Is there some sort TSQL that would allow me to search across multiple stored procedures for a specific line of text... more specifically "INSERT INTO [tablename]"</p>
  
  <p>UPDATE</p>
  
  <p>I've tried using:</p>
  
  <pre><code> SELECT routine_name, routine_type  
   FROM INFORMATION_SCHEMA.ROUTINES  
   WHERE ROUTINE_DEFINITION LIKE '%INSERT INTO [tablename]%' 
  </code></pre>
  
  <p>Straight out, replacing [tablename] with the name of my table.  This returns 0 rows.</p>
  
  <p>I DO have a procedure with that exact line in it, and I would have assumed that it would have been returned in the above query, but its not bringing back anything at all.</p>
  
  <p>UPDATE #2</p>
  
  <p>After using the redgate sql search tool (using INSERT INTO [tablename]) it returns 1 sp, but i'm still in denial that this is correct due to some of the tsql (at the end of the sp its dropping tables that are still in the database...) (this is where my in-experience at sql shines through)</p>
  
  <p>I still cant find where this is being called from though...</p>
  
  <p>UPDATE #3</p>
  
  <p>I just did a search on the entire solution for 'INSERT INTO [tablename]' to see if they maybe DIDN'T use a stored procedure for this call, and nothing... didn't find it anywhere.</p>