Created
March 10, 2026 10:47
-
-
Save MarkPryceMaherMSFT/32f9e21deb2f784bbb47b2d50f71d412 to your computer and use it in GitHub Desktop.
query to get the datatypes for each column
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 | |
| s.name AS SchemaName, | |
| t.name AS TableName, | |
| c.name AS ColumnName, | |
| ty.name AS DataType, | |
| c.max_length, | |
| c.precision, | |
| c.scale, | |
| c.is_nullable | |
| FROM sys.tables t | |
| JOIN sys.schemas s ON t.schema_id = s.schema_id | |
| JOIN sys.columns c ON t.object_id = c.object_id | |
| JOIN sys.types ty ON c.user_type_id = ty.user_type_id | |
| ORDER BY | |
| s.name, | |
| t.name, | |
| c.column_id; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment