Search for A Text/String In Any Stored Procedures using SQL Server

It’s really easy to find table dependencies using SQL Server Management Studio but there is really no “search for procedure text” in SQL Server.  We recently had to search for this kind of ‘dependencies’ since some of the stored procedures that we have had the table’s value hard coded in the stored proc (bad programmer! *electrocuted*).


SELECT obj.Name SPName, sc.TEXT SPText
FROM sys.syscomments sc
INNER JOIN sys.objects obj ON sc.Id = obj.OBJECT_ID
WHERE sc.TEXT LIKE '%' + '''IAmAwesome''' + '%'
AND TYPE = 'P'

Advertisements

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: