Sunday, February 4, 2007

Display column description for SQL Server 2005

Each table column has a 'description' field, which is an extended property.
This is a way to retrieve extended properties for a database:

SELECT AS [Table Name], AS [Column Name], value AS [Extended Property]
FROM sys.extended_properties AS ep
INNER JOIN sys.tables AS t ON ep.major_id = t.object_id
INNER JOIN sys.columns AS c ON ep.major_id = c.object_id AND ep.minor_id = c.column_id
WHERE class = 1

No comments: