How to search all tables in a database using SQL Server Management Studio?

I'm trying to find an easy way to search though every table in a database to find instances of a particular field value (regardless of column name).  I'm trying to find all instances of a particular invoice number.  The column headings will be different in different tables.

I am having a hard time tracking an sql query online to do this.
bradlee27514Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sm394Commented:
sorry chapmandew :)
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

chapmandewCommented:
;)  no problem at all..its a good one.  
0
bradlee27514Author Commented:
i've never created a stored procedure.  would i just go to the database, right click and go to "new query"  sorry if this is a dumb question, i've just never created one before.
0
chapmandewCommented:
yep, that is all you need to do...
0
bradlee27514Author Commented:
wow that's awesome, anyway to get it to only return exactly that string?  Its including results where the string is part of the whole field value.  For example searching for '0000031' also yields 'abc00000031'.
0
chapmandewCommented:
try this instead  ' 0000031'
0
bradlee27514Author Commented:
Confused, that is what i'm doing.
EXEC SearchAllTables '0000031'
GO

Open in new window

0
chapmandewCommented:
EXEC SearchAllTables ' 0000031'
GO
0
bradlee27514Author Commented:
Sorry, i didn't see the space.  that yields 0 results, should be at least 1 results
0
bradlee27514Author Commented:
thanks so much!  it'd be nice to further refine, but  this definitely works.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.