Simple search the whole database

Search throughout the database – MSSQL

If we’ve got large database and we need to find some procedure or view. And we do not remember what it was called but we know what string or parameters it return or contains.
We can search our database for a simple query.

SELECT DISTINCT
       o.name AS Object_Name,
       o.type_desc
  FROM sys.sql_modules m
       INNER JOIN
       sys.objects o
         ON m.object_id = o.object_id
 WHERE m.definition Like '%Order%';

As a result, we get the names of views/procedures that contain our keyword.
search sql

Of course we can clearly specify what we are looking for then we will get more narrow results.

Leave a Reply

Your email address will not be published. Required fields are marked *