Click here to Skip to main content
Click here to Skip to main content

Tagged as

Get given string instance from SQL database

, 19 Jan 2011 CPOL
Rate this:
Please Sign up or sign in to vote.
This is a SQL query to search particular string instance from SQL database.
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 case statements to check the status.
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, with routine_type = 'procedure' or as per requirement.
 
Hope it helps.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

That's Aragon
Software Developer (Senior)
India India
No Biography provided

Comments and Discussions

 
GeneralThank you for the comment and vote Gandalf! PinmemberThat's Aragon27-May-11 4:36 
GeneralReason for my vote of 5 Thanks for Sharing, It helped me. PinmemberGandalf - The White27-Jan-11 2:58 
GeneralThanks for comment Lyra. PinmemberThat's Aragon19-Jan-11 1:26 
GeneralGood tip Aragon, Thanks. PinmemberLyra Belaqua19-Jan-11 1:05 
GeneralThank you Pranay. :) PinmemberThat's Aragon19-Jan-11 0:43 
GeneralReason for my vote of 4 thanks for sharing... PinmemberPranay Rana19-Jan-11 0:26 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 19 Jan 2011
Article Copyright 2011 by That's Aragon
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid