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
 Seach Tables for a Column Name

Author  Topic 

bcarney
Starting Member

7 Posts

Posted - 2012-06-14 : 08:07:59
I am working with a DB that has approx. 3000 tables and views. Is there a way to search and identify all tables or views with a specific column name?


Thanks in advance
Brian

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2012-06-14 : 08:09:04
select
t.name as tablename,
s.name as columnname
from sys.objects t
join sys.columns s
on s.Object_Id = t.Object_Id
where s.name like '%searchvalue%'
order by t.name,s.name


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

bcarney
Starting Member

7 Posts

Posted - 2012-06-14 : 08:10:38
Great! Thanks for the Help...


Brian



Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2012-06-14 : 12:18:19
or just

SELECT *
FROM INFORMATION_SCHEMA.COLUMNS
WHERE COLUMN_NAME like '%searchvalue%'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -