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
 General SQL Server Forums
 New to SQL Server Programming
 Return all tables that contain a specific field

Author  Topic 

Sql newbie1
Starting Member

8 Posts

Posted - 2011-03-03 : 17:29:18
Hi guys

Does anyone know if its possible to run a query to return all tables that contain a specific field?

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-03 : 17:30:29
Yes:

select TABLE_NAME
from INFORMATION_SCHEMA.COLUMNS
where COLUMN_NAME = 'TheColumnNameToSearch'
order by TABLE_NAME

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 2011-03-03 : 17:49:50
tsk...

Tables don't contain "fields"



Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx


Want to help yourself?

http://msdn.microsoft.com/en-us/library/ms130214.aspx

http://weblogs.sqlteam.com/brettk/

http://brettkaiser.blogspot.com/


Go to Top of Page

Sql newbie1
Starting Member

8 Posts

Posted - 2011-03-04 : 03:23:59
Sorry column, thanks tkizer
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-03-04 : 05:50:45
You're welcome, glad to help.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
   

- Advertisement -