Solved

Searching for string in all tables?

Posted on 2008-06-17
4
205 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free eBook: Backup on AWS

Everything you need to know about backup and disaster recovery with AWS, for FREE!

Question has a verified solution.

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

Data architecture is an important aspect in Software as a Service (SaaS) delivery model. This article is a study on the database of a single-tenant application that could be extended to support multiple tenants. The application is web-based develope…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

734 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