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)
 Need a query to find a table by two of its column

Author  Topic 

meefozio
Starting Member

2 Posts

Posted - 2011-07-20 : 18:00:03
I work in software quality assurance. Oftentimes I am trying to figure out from which table data is being pulled, but the database has thousands of tables to look through. Instead of looking through all the tables, I just take a guess at one of the column names and execute a query like this:

SELECT table_name FROM information_schema.columns WHERE column_name like '%pur%code%'

That usually works, but occassionally it can return hundreds of table names which doesn't help me much. Instead, I'd like to form a query that could take two column names and return all the tables that have those columns.

So, in English, I want to say:

"Give me the names of all the tables that have a column named like %pur%code% and another column named like %client%loc%"

I would use something like INTERSECT, but my employer is running SQL SERVER 2000 and INTERSECT wasn't yet implemented.

Does anyone know how I can accomplish this?

meefozio
Starting Member

2 Posts

Posted - 2011-07-20 : 18:27:30
Nevermind, I found my own answer:

http://msdn.microsoft.com/en-us/library/aa213261(v=sql.80).aspx
Go to Top of Page
   

- Advertisement -