Created
December 12, 2018 21:10
-
-
Save bthaman/3f135b80dd3af161a40b4e747762df07 to your computer and use it in GitHub Desktop.
For a SQL Server database, lists tables and fields in each for user tables.
This file contains 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 T.name AS Table_Name , | |
C.name AS Column_Name , | |
P.name AS Data_Type , | |
P.max_length AS Size , | |
CAST(P.precision AS VARCHAR) + '/' + CAST(P.scale AS VARCHAR) AS Precision_Scale | |
FROM sys.objects AS T | |
JOIN sys.columns AS C ON T.object_id = C.object_id | |
JOIN sys.types AS P ON C.system_type_id = P.system_type_id | |
WHERE T.type_desc = 'USER_TABLE'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment