STAY IN TOUCH

Get New posts delivered straight to your inbox

  • Madeira Team

How to Find Objects that Contain a Certain String in SQL Server

Let’s say you remember a piece of code you need to optimize or take a look at, but you don’t remember in which stored procedure you saw it.

The following script searches for a certain string inside the code of all programmatic objects in the database (stored procedures, triggers, views and user defined functions), and returns the objects which contain it.

Transact-SQL

select object_name(object_id) as object_name,definition from sys.sql_modules where definition like '%Your String Here%'

1

2

3

select object_name(object_id) as object_name,definition

from sys.sql_modules

where definition like '%Your String Here%'

#DMVs #scripts

JOIN OUR MAILING LIST

CONTACT US

 3 Rapaport St. Kfar Saba, Israel

 +972-9-7400101

  • Google+ - White Circle
  • Facebook - White Circle
  • Twitter - White Circle
  • LinkedIn - White Circle