Beyondrelational

Wednesday, June 9, 2010

How to find all tables where a column occurs?

Execute the following script in Query Editor to find all occurances of the "addressid" column:
use AdventureWorks;
select
[Schema]=s.name,
[Table]=o.name,
[Column]=c.name
from sys.columns c
join sys.objects o
on c.object_id=o.object_id
join sys.schemas s
on s.schema_id=o.schema_id
where c.name='addressid'
order by [Table]

No comments:

Post a Comment