#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Posts
    1
    Rep Power
    0

    How to search the whole database tables in all fields for a specific value


    Hi to all,

    I'm not that good in database yet but I want to learn, but I'm currently facing a problem and I'm bounded by deadline, I'm currently looking for a certain table in a database that contains a specific value but the problem is that there are more than 100 tables in the database also every table there are more than 10-30 fields which makes it very troublesome to do an individual search or select statement per table per field thus I would like to ask for anyone who could help me if you know how to create a global select or search statement/ procedure or anything that could search the whole database tables regardless of any field were the value would reside. thanks.


    Here is the sql statement to retreive all database tablefields

    select TABLE_NAME, COLUMN_NAME from INFORMATION_SCHEMA.COLUMNS
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2007
    Posts
    168
    Rep Power
    7
    I suggest you run the output of this query then search for the text in the output hopefully your database is not too big.
    Code:
    select 'select '''+(name)+''', * from '+name from sys.objects where type='U'

IMN logo majestic logo threadwatch logo seochat tools logo