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)
 Finding all tables with a particular column name

Author  Topic 

DarrenHambleton
Starting Member

1 Post

Posted - 2008-11-21 : 12:03:20
Hi Guys,

I would like to generate a list of all tables within a database which has a Column "CUSTNMBR"

Cheers


Darren

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 12:12:07
[code]SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS WHERE COLUMN_NAME='CUSTNMBR'[/code]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-11-21 : 12:13:27
if you want to exclude views modify it as

SELECT TABLE_NAME FROM INFORMATION_SCHEMA.COLUMNS c
INNER JOIN INFORMATION_SCHEMA.TABLES t
ON t.TABLE_NAME=c.TABLE_NAME
WHERE c.COLUMN_NAME='CUSTNMBR'
AND t.TABLE_TYPE='BASE TABLE'
Go to Top of Page
   

- Advertisement -