SELECT Case whenCol.colorder= 1 ThenObj.nameELSE "' END astable name, Col.colorder asserial number, Col.name ascolumn name,ISNULL(ep.[value],"') ascolumn description, T.name asdata type, Col.length aslength,ISNULL(ColumnProperty(Col.id, Col.name,' Scale'),0) asNumber of decimal digits, Case when ColumnProperty(Col.id, Col.name,'isidentity')= 1 Then '√' ELSE "' END asidentification, Case when EXISTS(SELECT 1 fromdbo.sysindexes siINNER JOINDbo.sysindexkeys Sik onSi.id=sik.id andSi.indid=Sik.indidINNER JOINDbo.syscolumns SC onSc.id=sik.id andSc.colid=Sik.colidINNER JOINDbo.sysobjects so onSo.name=Si.name andSo.xtype= 'PK' WHERESc.id=col.id andSc.colid=Col.colid) Then '√' ELSE "' END asprimary KEY, Case whenCol.isnullable= 1 Then '√' ELSE "' END asallow NULL,ISNULL(Comm.text,"') asDefault Value fromDbo.syscolumns Col Left JOINDbo.systypes T onCol.xtype=T.xusertypeInner JOINDbo.sysobjects obj onCol.id=obj.id andObj.xtype= 'U' andObj.status>= 0 Left JOINDbo.syscomments Comm onCol.cdefault=comm.id Left JOINSys.extended_properties EP onCol.id=ep.major_id andCol.colid=ep.minor_id andEp.name= 'ms_description' Left JOINSys.extended_properties Eptwo onObj.id=eptwo.major_id andeptwo.minor_id= 0 andEptwo.name= 'ms_description'WHEREObj.name= 'Sys_fbryxx'--Table nameORDER byCol.colorder;
Reproduced in: https://www.cnblogs.com/yycxy/archive/2012/05/08/2490603.html
Reproduced Ms SQL SELECT get field description/table structure etc.