What does the Script do?
This script takes a search String and looks for it in all the procedures on an instance (yes instance), so if you have many databases in an instance (i.e. in my work place one Instance may have 50 to 70 databases) it will find them. If I need to find a procedure within all of these databases it becomes really cumbersome. The script will loop thru all the Databases and look for your search term. The script will also look for your term in all the jobs in that instance.
Once it finds the search term it will return the Database it is stored in, when it was created, the last time it was edited, whether it is a Procedure or a job, and if it is a job it will tell you what step in the job it’s in. Most importantly it will also provide the code so you can copy and paste it to a text editor if you need a quick view (The only drawback is the code is displayed as one line.)
The columns returned by the script are: ObjectID, Database, ObjectType or JobName, StepName, ProcName, CreationDate, ModifiedDate, Code, rn
How to Use:
Just enter a search word where indicated below. If you wish to filter based on creation time of Procedure or JOB you can enter values below. I have the 2 lines commented out here but you can change that as you see fit.
In order to filter by Object you must enter a valid Object as defined by SQL. These are the valid Objects:
CHECK_CONSTRAINT
DEFAULT_CONSTRAINT
FOREIGN_KEY_CONSTRAINT
SQL_SCALAR_FUNCTION
CLR_SCALAR_FUNCTION
CLR_TABLE_VALUED_FUNCTION
SQL_INLINE_TABLE_VALUED_FU
INTERNAL_TABLE
SQL_STORED_PROCEDURE
CLR_STORED_PROCEDURE
PLAN_GUIDE
PRIMARY_KEY_CONSTRAINT
RULE
REPLICATION_FILTER_PROCEDU
SYSTEM_TABLE
SYNONYM
SERVICE_QUEUE
CLR_TRIGGER
SQL_TABLE_VALUED_FUNCTION
SQL_TRIGGER
TABLE_TYPE
USER_TABLE
UNIQUE_CONSTRAINT
VIEW
EXTENDED_STORED_PROCEDURE
If you need to search for these Objects just use '' as the search string and it will return all the Objects of the type entered.
Any feedback would be greatly appreciated.