SQL SERVER 2008 导出字段类型、字段长度、字段备注等信息

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

SQL SERVER 2008 导出字段类型、字段长度、字段备注等信息

SELECT sysobjects.name AS 表名, syscolumns.name AS 列名, 
systypes.name AS 数据类型, syscolumns.length AS 数据长度, CONVERT(char, 
sysproperties.[value]) AS 注释
FROM  sys.extended_properties sysproperties RIGHT OUTER JOIN
sysobjects INNER JOIN
syscolumns ON sysobjects.id = syscolumns.id INNER JOIN
systypes ON syscolumns.xtype = systypes.xtype ON 
sysproperties.major_id = syscolumns.id AND 
sysproperties.minor_id = syscolumns.colid
WHERE (sysobjects.xtype = 'u' OR
sysobjects.xtype = 'v') AND (systypes.name <> 'sysname')
--and CONVERT(char,sysproperties.[value]) <> 'null' --导出注释不为'null'的记录
AND (sysobjects.name = 'TB_Bus_TDCB') --逐个关联表名,可以用or连接条件
ORDER BY 表名,syscolumns.colid

 

转载于:https://my.oschina.net/u/1986568/blog/1922576

你可能感兴趣的:(SQL SERVER 2008 导出字段类型、字段长度、字段备注等信息)