查看並導出SQL Server 數據表中字段的注釋信息
此示例為導出某個表注釋的語句(表名是bbs_bank_log)
SELECT sysobjectsname AS 表名 syscolumnsname AS 列名
systypesname AS 數據類型 syscolumnslength AS 數據長度 CONVERT(char
sysproperties[value]) AS 注釋
FROM sysproperties RIGHT OUTER JOIN
sysobjects INNER JOIN
syscolumns ON sysobjectsid = syscolumnsid INNER JOIN
systypes ON syscolumnsxtype = systypesxtype ON
syspropertiesid = syscolumnsid AND
syspropertiessmallid = syscolumnscolid
WHERE (sysobjectsxtype = u OR
sysobjectsxtype = v) AND (systypesname <> sysname)
and CONVERT(charsysproperties[value]) <> null 導出注釋不為null的記錄
AND (sysobjectsname = bbs_bank_log) 逐個關聯表名可以用or連接條件
ORDER BY 表名
注意事項
上文中的語句是導出某個表的所有注釋如果你需要簡單的列出表的所有注釋語句如下
SELECT CONVERT(char [value]) AS Expr
FROM sysproperties
sysobjects是系統對象表syscolumns是系統字段信息表systypes是系統類型表通過字段的ID和sysproperties(系統注釋屬性表)關聯即可讀出注釋信息
From:http://tw.wingwit.com/Article/program/SQL/201311/16240.html