Results 1 to 4 of 4
  1. #1
    Join Date
    Dec 2012
    Posts
    63

    Unanswered: searching for values within a database. Require more efficient method

    Hello Again!

    so ive been given read access to a database and I also am looking at a GUI which draws data from the database.
    I am trying to map the results I see from the GUI to find the columns that the data is in...

    so.. big database, takes a long time to search the entire thing so I try to narrow it down by the following:

    Code:
    select * from information_schema.columns where table_schema = 'db19' and table_catalog = 'masterdb' and 
    table_name in(select table_name from information_schema.tables where table_type = 'base table' and table_catalog = 'masterdb' and table_schema = 'db19' and data_type in ('text' and 'varchar'))
    this essentially gives me a list of tables and columns whos data type is either text or varchar.
    once I have this list... I then run the following on each:

    Code:
    select top 1 [col_name] from [table_name] where [col_name] like ' (here is the value I want to search) '
    so this runs through each table, looking to see if a value exists and if so, prints the result.
    I am then left with a much much smaller list that I can manually look through and find the one I am looking to specifically find.

    Questions
    1. Is there a better way of doing this?
    2. Is it possible to do this running only one query... where the output gives me all the columns in with a specific data type that contain a value I enter Anything else to make this more efficient


    I am aware that there are data mining programs that could probably do this however I only have read access on the database which often causes a problem. The application I am using is "Aqua Data Studio" if that helps...

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    If the Full-Text Search feature is installed and enabled for this database, then there is a fast and easy answer.

    If not, then there are ways to improve the performance of your search, but not as much.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Dec 2012
    Posts
    63
    Quote Originally Posted by Pat Phelan View Post
    If the Full-Text Search feature is installed and enabled for this database, then there is a fast and easy answer.

    If not, then there are ways to improve the performance of your search, but not as much.

    -PatP
    im slightly confused here... whats the difference between contains(x,'55') and
    Code:
    where x = '55'
    additionally, does this not only search a single columns?

  4. #4
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    I have not used full text in a while, but you can define a catalog over multiple columns as I remember.
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •