DISQUS

Tech-Recipes: SQL Server 2005: Locating Stored Procedures that Contain a Keyword

  • sleakbug · 11 months ago
    In SQL 2000 you will need to join together all the 8K records in syscomments for each stored procedure to search within, and beware of your search term breaking across an 8K boundary between 8K records. That will require creating a record that includes the last 1000 chars of one record + the first 1000 chars of the next record to include in the search. You may use less than 1000 chars depending on the size of your search terms.
  • Dan Wygant · 9 months ago
    Thanks! good info. Here is the OBJECT_NAME built-in for SS05 and beyond... I'm on ss08 now.

    select OBJECT_NAME(m.object_id), m.definition from sys.sql_modules m where
    Definition like '%YourKeyword%'

    Frankly I like yours better