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 2012 Forums
 Transact-SQL (2012)
 If a Column name exists in a database and where.

Author  Topic 

tshaw20832
Starting Member

10 Posts

Posted - 2014-07-10 : 09:46:15
All,

I am trying to figure out how to find out if a Column name exists and where in a database. There are 123 tables.

Thank you,

T

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2014-07-10 : 09:51:26
[code]SELECT object_name(object_id) as table_name
FROM sys.columns
WHERE name = 'a_column_name'
[/code]

similarly, you can also query INFORMATION_SCHEMA.COLUMNS to get the information you want


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

tshaw20832
Starting Member

10 Posts

Posted - 2014-07-10 : 10:14:12
Thank you very much. That is exactly what I needed. You are a life saver.
Go to Top of Page
   

- Advertisement -