SQL Clone
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

String-search on objects in a specified database

By anonuser,

Procedure 'p_find_string' allows users to specify any database on a server in searching for a specified character string.  Supported for string-searching:  table columns, view columns, trigger, function, and procedure code.  Produces a report showing: object type, owner, object name, column id (for tables and views) or what line number (for triggers, functions, and procedures), and the name and definition (for tables and views) or the line of code (for triggers, functions, and procedures).

Example:  Search the pubs database for all columns and lines of code containing the string 'author':

EXEC p_find_string @p_string = 'author'
                 , @p_dbname = 'pubs'

Pre-requisites:  Functions 'f_contains' and 'f_delimited', and stored procedure 'p_get_column_attribute', which I previously submitted.

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

String Search

Search for a string value within columns of data types CHAR, NCHAR, NTEXT, NVARCHAR, TEXT, VARCHAR, ...


Search for a String in all Stored Procedures and beyond?

Search for String Occurence with this script in your stored procedures.


Object Search

Procedure to search any database (or a combination of databases, including all) for a specific strin...


Simple Object and String Search within Objects

This Simple script will help to do a Server wide search for an object name or usage of a String in O...