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

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

Enter the CAPTCHA * Time limit is exhausted. Please reload CAPTCHA.