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)
 Search a single data in the entire tables in the database

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-05-11 : 07:47:11
unr8d writes "What would be the efficient way to search a single data with a given value in the entire tables in the database?

I have a table called 'Translate' that stores the table ID(identity col), the selected language ID(int), actual text value (text), and translation ID(int) in the database.

To enable multi-linlgual features in the web applicaiton, all text values are stored in one place, 'Translate' table everytime inserted.

For instance, having 2 language enabled in the application the text value 'Mister' is stored like this:
ID:1   Text:Mister   LangID:1(English)   TID(Translation ID):1
ID:2   Text:Monsieur   LangID:2(French)   TID:1

And most of tables with text value column(s) that needs to be translated in the database has the translate ID referencing to 'TID' column in this table to get actual text value.
The translation column name starts with 'tid...' consistently over every table.

i.e
'Salutation' table has a column called 'tidSalutation' (int) that stores the translation ID to 'Translate' table.So depending on the language ID, the actual text value for tidSalutaton=1 can be either 'Mister' in English or 'Monsieur' in French.

Now I want to find the data with given TID (translation ID), search tables (150 tables with 'tid...' columns with about 15000 raws) in the database, and find out which table the data comes from and which column it is.

Taking the prev. example, I want to find the data with TID=1, in which table, in which column, etc...
I can call sysobjects and syscolumn tables to find out all the 'tid...' columns in the tables in the database and then scan each table for this given TID. But it is quite slow (esp. on web).

Is there any better and efficient way to achieve this?"

X002548
Not Just a Number

15586 Posts

Posted - 2005-05-11 : 09:55:16
I'm not sure I follow 100%, but if you want to scan a database (which is a bad thing that you don't know your database schema)

http://weblogs.sqlteam.com/brettk/archive/2005/02/08/4144.aspx



Brett

8-)
Go to Top of Page
   

- Advertisement -