sqlserver的一些查询方法

查询某个表的备注:

SELECT
    A.name AS table_name,
    B.name AS column_name,
    C.value AS column_description
FROM sys.tables A
INNER JOIN sys.columns B
    ON B.object_id = A.object_id
LEFT JOIN sys.extended_properties C
    ON C.major_id = B.object_id
        AND C.minor_id = B.column_id
WHERE A.name = 'tablea'

为某个表 或 某个字段添加备注:

EXECUTE sp_addextendedproperty N'MS_Description', '表', N'user', N'dbo', N'table', N'promon_soft_po', NULL, NULL 


EXECUTE sp_addextendedproperty N'MS_Description', '字段1', N'user', N'dbo', N'table', N'promon_soft_po', N'column', N'potype'

你可能感兴趣的:(sqlserver的一些查询方法)