Searching Object Definitions in MSSQL Database

Collection of snippets to use to search the database for objects containing  a searchstring.

DECLARE @Search varchar(255)
SET @Search='whatimlookingfor'
 
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 '%'+@Search+'%'
ORDER BY 2,1
-- Source JumpingJezza on StackExchange
Responses are currently closed, but you can trackback from your own site.

Comments are closed.

Powered by WordPress | Designed by: wordpress themes 2012 | Thanks to Best Free WordPress Themes, Find Free WordPress Themes and Free WordPress Themes