Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Search Entire Database for String

Posted on 2007-12-04
1
Medium Priority
?
3,461 Views
1 Endorsement
Last Modified: 2008-02-01
How do I go about searching an entire DB2 database for any instance of a string criteria?

i.e. Any field in any table with the string "%Testing%"
1
Comment
Question by:DJmistral
1 Comment
 
LVL 46

Accepted Solution

by:
Kent Olsen earned 500 total points
ID: 20404910
Hi DJmistral,

You'll have to query each table.

One way to do that is to write SQL to generate SQL.  A relatively common thing for DBAs to do.

SELECT 'SELECT * FROM ' || rtrim(table_schema) || '.' || table_name || ' WHERE ' || Column_name || ' like ''%Testing%'';'
FROM sysibm.columns
WHERE table_schema = ''
  AND table_name = ''
  AND DATA_TYPE = 'CHARACTER VARYING';

Replace the '' with the appropriate schema and table names and that QUERY will generate SELECT statements for you.  Copy and past them into the client window and execute them.


Good Luck,
Kent
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Recursive SQL in UDB/LUW (you can use 'recursive' and 'SQL' in the same sentence) A growing number of database queries lend themselves to recursive solutions.  It's not always easy to spot when recursion is called for, especially for people una…
Recursive SQL in UDB/LUW (it really isn't that hard to do) Recursive SQL is most often used to convert columns to rows or rows to columns.  A previous article described the process of converting rows to columns.  This article will build off of th…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question