MSSQL how to use sql statement to get the field description, field remark, field type, field length

Original: MSSQL How to use sql statement to get table creation field description, field remarks, field type, field length

Reprinted from: http://www.maomao365.com/?p=4983

<span style="color:red;font-weight:bold;">The
following description - use sql script to obtain the description information corresponding to all columns in the specified table, the
script is as follows:
</span>
 

SELECT 
( case  when a.colorder = 1  then d.name else  ''  end ) [ datatable name ] ,
a.colorder [ column order ] ,
a.name [ column name ] ,
b.name as  [ column type ] ,
b.length as  [ column length ] ,
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 ' -- data table name 
order  by a.id, a.colorder

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325227075&siteId=291194637