This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing a script to find the all columns information of a database in SQL Server.
This script is handy for reporting the metadata information of the database.
Database Developer can easily get a list of all column information like data type, max length.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
SELECT OBJECT_SCHEMA_NAME([T].[object_id],DB_ID()) AS SchemaName ,[T].[name] AS TableName ,[AC].[name] AS ColumnName ,[TY].[name] AS DataType ,[AC].[max_length] AS MaxLength ,[AC].[precision] AS ColumnPrecision ,[AC].[scale] AS ColumnScale ,[AC].[is_nullable] AS IsColumnNullable FROM sys.tables AS T INNER JOIN sys.all_columns AS AC ON [T].[object_id] = [AC].[object_id] INNER JOIN sys.types AS 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] |