此示例为导出某个表注释的语句:(表名是bbs_bank_log)
SELECT sysobjects.name AS 表名, syscolumns.name AS 列名,
systypes.name AS 数据类型, syscolumns.length AS 数据长度, CONVERT(char,
sysproperties.[value]) AS 注释
FROM sysproperties RIGHT OUTER JOIN
sysobjects INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype ON
sysproperties.id = syscolumns.id AND
sysproperties.smallid = syscolumns.colid
WHERE (sysobjects.xtype = 'u' OR
sysobjects.xtype = 'v') AND (systypes.name <> 'sysname')
--and CONVERT(char,sysproperties.[value]) <> 'null' --导出注释不为'null'的记录
--AND (sysobjects.name = 'bbs_bank_log') --逐个关联表名,可以用or连接条件
ORDER BY 表名
注意事项:
上文中的语句是导出某个表的所有注释,如果你需要简单的列出表的所有注释,语句如下:
SELECT CONVERT(char, [value]) AS Expr1
FROM sysproperties
sysobjects是系统对象表,syscolumns是系统字段信息表,systypes是系统类型表。通过字段的ID和sysproperties(系统注释属性表)关联,即可读出注释信息。
文章来源于领测软件测试网 https://www.ltesting.net/