Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Finding which table a particular value is stored?

Author  Topic 

Goalie35
Yak Posting Veteran

81 Posts

Posted - 2008-04-04 : 17:13:09
Hi guys.
I know how to write a query that returns all tables that contain a specified field (i.e. a search for "productID" may return the "Products" & "OrderItems" tables). I also know there's a way to search stored procedures in the same manner.

However, is there any way to return the tables/fields that contain a particular value in one of it's rows?

Basically, I have to find a particular table/field for my query that contains "job number's" but it's hidden somewhere amongst half a dozen servers, several hundred databases, and probably thousands of tables and so far, I've had no luck finding it.

I do however, know that one of the values within this field should be "15839933". If I could perform a query that returned all fields/tables that contain this "15839933" value in one of its rows, that would save me hours of manual searching.

Thanks in advance.
-Goalie35

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-04 : 17:59:43
There is no easy way to do this. The best that can be done is to script out a select statement for each column in each table.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-05 : 02:46:42
http://vyaskn.tripod.com/search_all_columns_in_all_tables.htm

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-04-05 : 12:30:59
Good one madhi. But i think he needs to find for all databases and servers.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-08 : 03:22:05
quote:
Originally posted by sodeep

Good one madhi. But i think he needs to find for all databases and servers.


Then OP must change the code accordingly

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -