Tuesday, January 31, 2012

Stored Procedure to Query Metadata

One must not forget that at the end of the day, databases store all metadata internally in a way which can be queried.

Therefore, in MS SQL, one can use the following query to search within stored procedures.

SELECT ROUTINE_NAME, ROUTINE_DEFINITION
FROM INFORMATION_SCHEMA.ROUTINES
WHERE ROUTINE_DEFINITION LIKE '%Reuben%'
AND ROUTINE_TYPE='PROCEDURE'

This query is used to search all stored procedures, which have the word Reuben within them.

No comments: