Once I had to get given string instance from SQL
database within the instances of my database objects, like from table, stored procedure, etc.
My role was to replace status text Active, Inactive, Pending and NA with something else provided by the client. I didn't know in how many stored procedures this status was used, but had information that all the item statuses were managed via stored procedures. For example, consider the member status. They were using
statements to check the
CASE WHEN Status = 0 THEN 'Active' WHEN Status = 1 THEN 'InActive' WHEN Status = 2 THEN 'Pending' ELSE 'NA' END AS MemberStatus
So, I used the following query to find the list of database objects in which to search for the particular term.
SELECT routine_name, routine_definition FROM information_schema.routines where routine_definition like '%Active%'
One can filter it based on the requirement, like
append AND condition
routine_type = 'procedure'
or as per requirement.
Hope it helps.