--query table structure startSELECTSerial number=A.colorder, field name=A.name, Field description=f.value, Logo= 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, Length= ColumnProperty(A.id,a.name,'PRECISION'), 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 F onf.major_id=D.id andf.minor_id=A.colorderwhereD.name=' table name' Order byA.id,a.colorder--query table structure end
SQL Server Query table structure