Solved

Searching for string in all tables?

Posted on 2008-06-17
4
169 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 500 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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now