Skip to content

Instantly share code, notes, and snippets.

@L3V147H4N
Created April 27, 2015 19:42
Show Gist options
  • Save L3V147H4N/a94538cc074603b9a272 to your computer and use it in GitHub Desktop.
Save L3V147H4N/a94538cc074603b9a272 to your computer and use it in GitHub Desktop.
SQL Server Get Database Schemas
SELECT t.name AS TableName,
SCHEMA_NAME(t.schema_id) AS SchemaName,
c.name AS ColumnName,
tp.name as DataType
FROM sys.tables AS t
INNER JOIN sys.columns c ON t.OBJECT_ID = c.OBJECT_ID
INNER JOIN sys.types tp ON c.system_type_id = tp.system_type_id
WHERE
tp.name <> 'sysname'
ORDER BY TableName;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment