查询某个表或者所有表的字段说明 SQLServer

Posted on 2014-07-12 09:07  南岗V哥  阅读(236)  评论(0编辑  收藏  举报

查询某个表或者所有表的字段说明
SELECT
    [Table Name] = OBJECT_NAME(c.object_id),
    [Column Name] = c.name,
    [Description] = ex.value
FROM
    sys.columns c
LEFT OUTER JOIN
    sys.extended_properties ex
ON
    ex.major_id = c.object_id
    AND ex.minor_id = c.column_id
    AND ex.name = 'MS_Description'
WHERE
    OBJECTPROPERTY(c.object_id, 'IsMsShipped')=0
    AND OBJECT_NAME(c.object_id) = 'B_CKD1'
ORDER
    BY OBJECT_NAME(c.object_id), c.column_id