24 April 2013

Get particular string instance from all stored procedures in the SQL database

I would like to share one issue and its solution with you. There were some award categories like "Platinum", "Gold", "Silver" etc used in SQL stored procedures. Now my client was like to update that categories name with something different.

I was totally unaware of the number of stored procedures that used these categories for comparison or any other task. So my task was to find and update particular string with other string in SQL

To decrease my search, I have used information_schema.routines as below.

SELECT routine_name, routine_definition  FROM information_schema.routines where routine_type = 'procedure' and routine_definition like '%Gold%'


Above query will list out all procedure name and its definition where definition contains word like "Gold" from the given database.

From the filtered list, we can easily apply our changes to the stored procedure.

Hope it will help you to narrow down your search in SQL.