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
 Transact-SQL (2000)
 Need to 'scan' multiple tables to find data

Author  Topic 

jej1216
Starting Member

27 Posts

Posted - 2007-06-13 : 18:08:15
We have an application that populates any one of twenty tables (named 1.0 , 1.1 , up to 2.9). We need to run a script that effectively says "look in any table with a name like "1." and display the ones with data in them."

We're on SQL Server 2000.

TIA,

jej1216


jej1216
Starting Member

27 Posts

Posted - 2007-06-13 : 18:09:42
Oops - wrong forum group - I meant to post this in the SQL Server 2000 area.

Can this be moved?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-06-13 : 18:20:03
The topic has been moved.

Tara Kizer
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-06-13 : 19:47:31
You can get the list of tables beginning with "1." via querying sysobjects.
 SELECT * FROM Sysobjects WHERE Name LIKE '1.%' 

Loop through this list and you can use dynamic sql to get a rowcount to see which table has data.

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-06-13 : 21:52:43
Please tell me this application is still in development and you still have the chance to use a proper, normalized database design! This sounds like a horrible mess.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -