Created
December 3, 2019 16:35
-
-
Save wbhinton/64fe9324d87563c4b7aa47b147ff6fdd to your computer and use it in GitHub Desktop.
Get the schema for an existing DB.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT OBJECT_SCHEMA_NAME(c.object_id) SchemaName | |
,o.Name AS Table_Name | |
,c.Name AS Field_Name | |
,t.Name AS Data_Type | |
,t.max_length AS Length_Size | |
,t.precision AS Precision | |
FROM sys.columns c | |
INNER JOIN sys.objects o ON o.object_id = c.object_id | |
LEFT JOIN sys.types t ON t.user_type_id = c.user_type_id | |
WHERE o.type = 'U' | |
-- and o.Name = 'YourTableName' | |
ORDER BY o.Name | |
,c.Name |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment