In this post, I provide one script to find all columns information of a database in SQL Server.
Actually, this script is very useful for report work of database meta data.
Database Developer can easily get a list of all column information like, datatype, maxlength and it can share other developer.
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]
Please share your ideas and opinions about this topic with me, your contribution will add true value to this topic.
If anyone has doubts on this topic then please do let me know by leaving comments or send me an email.
If you like this post, then please share it with others.
Please follow dbrnd.com, I will share my experience towards the success of Database Research and Development Activity.
I put up a post every day, please keep reading and learning.
Discover Yourself, Happy Blogging !
Anvesh M. Patel.