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_%';
Default image
Eric
Code guy.

Newsletter Updates

Enter your email address below to subscribe to our newsletter

Leave a Reply