欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

用sql 查询分析器查询表的字段类型长度和表说明

程序员文章站 2022-05-08 17:59:19
...
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 表名

 

相关标签: SQL BBS