Skip to content

Instantly share code, notes, and snippets.

@benmccallum
Created July 17, 2020 14:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benmccallum/1d781f8efddf7b292a1392aa8439a24d to your computer and use it in GitHub Desktop.
Save benmccallum/1d781f8efddf7b292a1392aa8439a24d to your computer and use it in GitHub Desktop.
Get db-wide columns info
select
schema_name(tab.schema_id) as schema_name,
tab.name as table_name,
--col.column_id,
col.name as column_name,
col.is_nullable,
t.name as data_type,
col.precision,
col.scale
from sys.tables as tab
inner join sys.columns as col
on tab.object_id = col.object_id
left join sys.types as t
on col.user_type_id = t.user_type_id
order by
schema_name,
table_name,
column_id;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment