Last active
December 14, 2016 02:27
-
-
Save RichardHan/fbb8efb870d8246da693651a3ae6f3f7 to your computer and use it in GitHub Desktop.
[SQL] Get All Columns Attributes From All Table
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(T.[object_id],DB_ID()) AS [Schema], | |
T.[name] AS [table_name], AC.[name] AS [column_name], | |
TY.[name] AS system_data_type, AC.[max_length], | |
AC.[precision], AC.[scale], AC.[is_nullable], AC.[is_ansi_padded] | |
FROM sys.[tables] AS T | |
INNER JOIN sys.[all_columns] AC ON T.[object_id] = AC.[object_id] | |
INNER JOIN sys.[types] TY ON AC.[system_type_id] = TY.[system_type_id] AND AC.[user_type_id] = TY.[user_type_id] | |
WHERE T.[is_ms_shipped] = 0 | |
ORDER BY T.[name], AC.[column_id] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment