Skip to content

Instantly share code, notes, and snippets.

@SqlBroveloper
Created November 14, 2017 05:31
Show Gist options
  • Save SqlBroveloper/1769a7f88e9f39b5059ae4f48524ac32 to your computer and use it in GitHub Desktop.
Save SqlBroveloper/1769a7f88e9f39b5059ae4f48524ac32 to your computer and use it in GitHub Desktop.
simple but useful metadata query
use AdventureWorks2014
go
select s.name as 'SchemaName',o.name as 'TableName',c.name as 'ColumnName'
from sys.schemas as s
inner join sys.all_objects as o
on s.schema_id = o.schema_id
inner join sys.all_columns as c
on c.object_id = o.object_id
where c.name like 'BusinessEntityId'
and o.type = 'U'
order by SchemaName,TableName,ColumnName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment