How do I find a text in SQL Object ?

 
Started with:
 
 
Adapted to:

ALTER PROCEDURE [Testing].[uspFindText]

@DatabaseName

nvarchar(50) = ‘EFI’
, @TextToFind nvarchar(100)
–, @Type int = 0 –0 = ALL, 1 = PROCEDURE

AS

DECLARE

@SQL nvarchar(500)
SELECT @SQL = ‘SELECT ROUTINE_TYPE, SPECIFIC_SCHEMA, ROUTINE_NAME, ROUTINE_DEFINITION
FROM [‘
+ @DatabaseName + ‘].INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE ”%’
+ @TextToFind + ‘%”’

–SELECT @SQL = @SQL + ‘ AND ROUTINE_TYPE=”PROCEDURE”’

PRINT

@SQL
EXECUTE(@SQL)

 
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: