MSSQL 如何采用sql语句 获取建表字段说明、字段备注、字段类型、字段长度
转自: http://www.maomao365.com/?p=4983
<span style="color:red;font-weight:bold;">
下文讲述-采用sql脚本获取指定表中所有列对应的说明信息,
脚本如下所示:
</span>
SELECT (case when a.colorder=1 then d.name else '' end) [数据表名称], a.colorder [列顺序], a.name [列名称], b.name as [列类型], b.length as [列长度], g.[value] AS [列说明信息] FROM syscolumns a left join systypes b on a.xtype=b.xusertype inner join sysobjects d on a.id=d.id and d.xtype='U' and d.name<>'dtproperties' left join sys.extended_properties g on a.id=g.major_id AND a.colid = g.minor_id WHERE d.[name] ='IError'--数据表名称 order by a.id,a.colorder