SELECTTable name= Case whenA.colorder=1 ThenD.nameElse "' End, table describes= Case whenA.colorder=1 Then IsNull(F.value,"')Else "' End, Field ordinal=a.colorder, field name=a.name, field description= IsNull(G.[value],"'), identify= Case when ColumnProperty(A.id,a.name,'isidentity')=1 Then '√'Else "' End, PRIMARY key= Case when exists(SELECT 1 fromsysobjectsWhereXtype='PK' andParent_obj=a.ID andNameinch ( SELECTName fromsysindexesWHEREIndidinch(SELECTIndid fromSysindexkeysWHEREId=a.ID andColid=A.colid))) Then '√' Else "' End, type=b.name, number of bytes occupied=a.length, Length= ColumnProperty(A.id,a.name,'PRECISION'), number of decimal digits= IsNull(ColumnProperty(A.id,a.name,' Scale'),0), allow null= Case whenA.isnullable=1 Then '√'Else "' End, the default value= IsNull(E.Text,"') fromsyscolumns A Left Joinsystypes B onA.xusertype=B.xusertypeInner Joinsysobjects D ona.id=D.id andD.xtype='U' andD.name<>'dtproperties' Left Joinsyscomments E onA.cdefault=e.id Left Joinsys.extended_properties G ona.id=g.major_id andA.colid=g.minor_id Left Joinsys.extended_properties F ond.id=f.major_id andf.minor_id=0 --where d.name= ' OrderInfo '--if only the specified table is queried, add this condition Order byA.id,a.colorder
MS SQL Server Export table structure to excel