Created
October 26, 2015 22:53
-
-
Save andyj/19567c6d0c03a8311814 to your computer and use it in GitHub Desktop.
Searching MSSQL database for a Stored Proc by T-SQL Definition
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sp_MSforeachdb 'SELECT "?" AS DB, | |
r.SPECIFIC_SCHEMA, r.routine_name, r.ROUTINE_DEFINITION, p.ORDINAL_POSITION, p.PARAMETER_MODE, p.PARAMETER_NAME, p.DATA_TYPE | |
FROM [?].INFORMATION_SCHEMA.ROUTINES r | |
JOIN [?].INFORMATION_SCHEMA.PARAMETERS p ON r.SPECIFIC_SCHEMA = p.SPECIFIC_SCHEMA AND r.SPECIFIC_NAME = p.SPECIFIC_NAME | |
WHERE | |
r.ROUTINE_TYPE = ''PROCEDURE'' | |
AND left(r.ROUTINE_NAME,2) <> ''dt'' | |
AND r.ROUTINE_DEFINITION LIKE ''%someSQLCode%'' | |
ORDER BY r.SPECIFIC_NAME ASC, p.ORDINAL_POSITION ASC' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment