Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with SQL query

Status
Not open for further replies.

steveot

IS-IT--Management
Joined
Oct 27, 2003
Messages
1,635
Location
US
I need a simple query or OSQL script to query the whole database ans search for a specific "string".

For example I want to search for "james" but I dont know what table its in.

 
why?

i mean, under what circumstances would you not know which tables you want to search in?

r937.com | rudy.ca
 
Did you know in what field you will search?

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Its a 3rd party database with many tables and I can figure out what table/colum/field this table is in. Other than that I know whow to write a simple select from table but I need search all tables.

Unless there is a way to capture or trace the data being entered..which I dont know how to do.
 
Sorry In my last comment I cant figure out what table this data is in
 
Try looking at the information schema.

Select * from information_schema.tables

Select * from Information_schema.columns

Those 2 queries should (hopefully) help you make intelligent guesses regarding columns that may contain your data.

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 

Like what you said, you can find the table and the field by openning the SQL profiler then tracing the SQL on all the databases.
 
I ask becuase you could use sp_MSforeachtable but you must know in what column you will do the search.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top