Description query the database table fields

--check sentence

SELECT 
    [Table Name] = OBJECT_NAME(col.object_id),
    [Column Name] = col.name,
    [Description] = ex.value 
FROM 
    sys.columns col 
LEFT OUTER JOIN 
    sys.extended_properties ex 
ON 
    ex.major_id = col.object_id
    AND ex.minor_id = col.column_id 
    AND ex.name = 'MS_Description' 
WHERE 
    OBJECTPROPERTY(col.object_id, 'IsMsShipped')=0 
     AND OBJECT_NAME(col.object_id) = 'UnitData'
ORDER 
    BY OBJECT_NAME(col.object_id), col.column_id

--search result:

The Description the Column the Name the Name the Table
UnitData self-energizing Id Id
UnitData UnitId Store Id
UnitData number SortNo

Reproduced in: https: //www.cnblogs.com/focuses/archive/2011/12/27/2303836.html

Guess you like

Origin blog.csdn.net/weixin_33935777/article/details/93486862