Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Search for an expression in the body of programmable objects

By Yousef Ekhtiari, 2006/11/30

Sometimes you want to modify an object (like a stored procedure, Function, trigger
and view) and you can not remember the name of that object, but you remember some
words of the comments that you placed in the body of that object.
If this is your case, you can use the following procedures depending on what version of SQL Server you are using.
It will search all the databases except system databases and if it finds any match, it will return the name and the type of that object.

By the way, this stored procedure is on its second edition.

Usage:

Consider you have the following comment in the body of your object:
"This is a test to test the efficiency of the stored proc!"
You can invoke the proc in the following ways:

Exec Usp_SearchInBodyOfCodes 'efficiency "This is a test" ', @flag='w'
It will search for the words "efficiency" and "This is a test" in the body of mentioned objects.

Exec Usp_SearchInBodyOfCodes 'efficiency "This is a test" ', @flag='a'
Will search for any word of "efficiency" or "This is a test" n the body of the objects

Consideration:

Best to view the results in Query Analyzer Results in Text (Control +T)
you can limit the databases in which you want Have fun with it, and if you like it vote for it....

Total article views: 148 | Views in the last 30 days: 1
 
Related Articles
SCRIPT

Database_Object_Last_used_details

I have implemented following stored procedure which is providing the object wise last used date of a...

FORUM

dynamic object(database/schema/obj) in stored procedure

how to reference multiple database/objects in stored procedure (parameterization)

BLOG

How to list all CLR objects inside your database?

I wrote the following query that returns the list of all CLR functions/procedures/objects exists ins...

ARTICLE

Migrating Database Objects

Not a fun task, although SQL Server 2000 makes the job easier than a few other platforms. Still it's...

SCRIPT

Easily delete database objects

The stored procedure sp_DropDatabaseObject is designed to easily drop a variety of database objects ...

Tags
t-sql    
 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones