SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
Register Now and get your question answered!
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 If a Column name exists in a database and where.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

10 Posts

Posted - 07/10/2014 :  09:46:15  Show Profile  Reply with Quote

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,


In (Som, Ni, Yak)

17684 Posts

Posted - 07/10/2014 :  09:51:26  Show Profile  Reply with Quote
SELECT object_name(object_id) as table_name
FROM   sys.columns
WHERE  name = 'a_column_name'

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

Time is always against us

Go to Top of Page

Starting Member

10 Posts

Posted - 07/10/2014 :  10:14:12  Show Profile  Reply with Quote
Thank you very much. That is exactly what I needed. You are a life saver.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.12 seconds. Powered By: Snitz Forums 2000