Search names of tables or stored procedures for arbitrary text

Sometimes you need to search for a stored procedures without knowing its exact name, or to find all of the procedures that begin with a certain naming prefix. Tables that follow a particular naming convention can be found by searching against the name in the same way.

-- Search table names
SELECT
    *
FROM
    INFORMATION_SCHEMA.TABLES
WHERE TABLE_NAME LIKE 'tmp_%';

-- Search stored procedure names
SELECT
    SPECIFIC_SCHEMA,
    ROUTINE_NAME
FROM
    INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_TYPE = 'PROCEDURE'
    AND ROUTINE_NAME LIKE 'tmp_%';
Eric
Eric

Code guy.

Articles: 18

Leave a Reply

Your email address will not be published. Required fields are marked *