Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Searching for string in all tables?

Posted on 2008-06-17
4
Medium Priority
?
221 Views
Last Modified: 2010-03-19
I'd like to loop through all tables in a database searching for a particular string.  The column this string might be in isn't known ahead of time.   Basically, this is a blind search.
0
Comment
Question by:brettr
  • 2
  • 2
4 Comments
 
LVL 60

Expert Comment

by:chapmandew
ID: 21805649
0
 

Author Comment

by:brettr
ID: 21806190
Thanks.  It doesn't give the column name.  Just its type.  How do I get it to display the column and table name?

Also, I can only run it once and then get the error

There is already an object named '#Results' in the database.

I have tried
Delete #Results

and disconnecting/reconnecting with no luck.
0
 
LVL 60

Accepted Solution

by:
chapmandew earned 2000 total points
ID: 21806242
try
drop table #results instead...

also, at the very end, instead of this:

SELECT ColumnName, ColumnValue FROM #Results

do this:

select * from #Results
0
 

Author Comment

by:brettr
ID: 21806686
There's only two columns in #Results.  The ColumnName is still giving [dbo].[StringTable].[String].
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction This article will provide a solution for an error that might occur installing a new SQL 2005 64-bit cluster. This article will assume that you are fully prepared to complete the installation and describes the error as it occurred durin…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

916 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