SQL SP to search for string in all tables in a DB

Share on facebook
Share on twitter
Share on linkedin

When working on SQL databases, from time to time you feel the need to search for a integer / string in all the tables of a databses. I found these solutions handy.

a. Search for a string in all tables of SQL Server Database

b. Searching and finding a string value in all columns in a SQL Server table

c. Search entire SQL Server database and all tables for a specified string

I wanted to search for a string while I was working on MS Project server database in production. This query solved my purpose.

1. Run the script (go to url above) in Query Analyzer for the database in which you want to search for a integer / string

2. Use the syntax mentioned or try one in the examples section to search for integer / string
3. View the results by querying the ##tmpSearchResult table

(Imp: Play with the script in your testing environment then use in production. Use it at your own risk.)

Leave a Reply

Sign up for Softvative Newsletter

Receive the latest technology and leadership news and resources from us

Subscribe To Softvative Newsletter

Get notified about new articles

Share on facebook
Share on twitter
Share on linkedin
Share on pinterest