FInd text in Stored Procedure, Function, View or Trigger

Following query can be use to search any text in SQL Server –

SELECT DISTINCT
s.name+’.’+o.name AS Object_Name,o.type_desc, o.[Type]
FROM sys.sql_modules m
INNER JOIN sys.objects o ON m.object_id=o.object_id
INNER JOIN sys.schemas s ON o.schema_id=s.schema_id
WHERE m.definition Like ‘%FN_Accounts_GetLedgerOpeningBalance%’
–AND o.Type=’P’ –<uncomment if you only want to search procedures
–AND o.Type=’FN’ –<uncomment if you only want to search procedures
ORDER BY [Type]

Advertisements
Posted in Uncategorized. Leave a Comment »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: