Search all fields in all tables of a SQL Database

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How can I seach all of the fields of every table in a databae for a particular value. When it is found, I want to be able to display the table name and the field name, then continue to search.
 
The same way you would search a normal SQL table for all fields...

First, get the schema...

then... for each table... get a list of fields...

then for each row, validate against each field to see if the value is
there....

return...

move on...

The trick is of course, speed... And this is why indexes were invented.
KRoy said:
How can I seach all of the fields of every table in a databae for a
particular value. When it is found, I want to be able to display the table
name and the field name, then continue to search.
 
* "=?Utf-8?B?S1JveQ==?= said:
How can I seach all of the fields of every table in a databae for a
particular value. When it is found, I want to be able to display the
table name and the field name, then continue to search.

That's a typical question for the ADO.NET group:

<
 
Hi KRoy,

It's quite an open-ended question. Like so many postings I end up asking
for a few more details. It is so atypical to think that somebody would want
to search every column of every table in a database for (for instance) the
word "computer" or something. Equals "computer" or contains "computer"?
Would you want it to match on the word "compute" also in that case?

If you could describe what it is that you are trying to do in a big picture
view it might be easier to propose a solution. Perhaps the answer is to
post the text values into a special "search" table in addition to posting in
the regular tables. Suddenly it becomes significantly easier since all
searching would be done in a single table on a single field. Table and
primary key information would be contained in the search table so you could
refer back to the original source.

So to answer your question, "it depends." :-)

Tom

KRoy said:
How can I seach all of the fields of every table in a databae for a
particular value. When it is found, I want to be able to display the table
name and the field name, then continue to search.
 
Back
Top