Solved

Searching for string in all tables?

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

[Webinar] Disaster Recovery and Cloud Management

Learn from Unigma and CloudBerry industry veterans which providers are best for certain use cases and how to lower cloud costs, how to grow your Managed Services practice in IaaS clouds, and how to utilize public cloud for Disaster Recovery

Question has a verified solution.

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

There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…

867 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

12 Experts available now in Live!

Get 1:1 Help Now