在sql server中,导出某个表注释的语句:(表名为:bbs_bank_log)
sql语句:
复制代码 代码示例:
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.idINNER 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(系统注释属性表)关联,就可以读出注释信息