1 SELECT2Table name= Case whenA.colorder=1 ThenD.nameElse "' End,3Table description= Case whenA.colorder=1 Then IsNull(F.value,"')Else "' End,4Field ordinal=A.colorder,5Field name=A.name,6Identity= Case when ColumnProperty(A.id,a.name,'isidentity')=1 Then '√'Else "' End,7Primary key= Case when exists(SELECT 1 fromsysobjectswhereXtype='PK' andNameinch (8 SELECTName fromsysindexesWHEREIndidinch(9 SELECTIndid fromSysindexkeysWHEREId=a.ID andColid=A.colidTen))) Then '√' Else "' End, OneType=B.name, ANumber of bytes occupied=A.length, -Length=ColumnProperty(A.id,a.name,'PRECISION'), -Number of decimal digits=IsNull(ColumnProperty(A.id,a.name,' Scale'),0), theAllow empty= Case whenA.isnullable=1 Then '√'Else "' End, -Default value=IsNull(E.text,"'), -Field description=IsNull(g.[value],"') - fromsyscolumns a + Left JoinSystypes b onA.xusertype=B.xusertype - Inner Joinsysobjects D ona.ID=D.id andD.xtype='U' andD.name<>'dtproperties' + Left Joinsyscomments E onA.cdefault=e.id A Left JoinSys.extended_properties g ona.ID=g.major_id andA.colid=g.minor_id at Left JoinSys.extended_properties F onD.id=f.major_id andf.minor_id=0 - whereD.name='merchandisecomment' --If you query only the specified table, add this condition - Order byA.id,a.colorder
SQL Server 2008 Get field comments for table