Select
Obj.name as ' table name '
, c.name as ' field name '
, T.name as ' field type '
, c.length as ' consumes bytes '
, ColumnProperty (c.id,c.name, ' PRECISION ') as ' length '
, IsNull (ColumnProperty (c.id,c.name, ' scale '), 0) as ' decimal digits '
, Case (c.isnullable) Time ' 1 ' then ' √ ' else ' end as ' is null '
, ISNULL (Cm.text, ') as ' default value '
, Case (
(select 1 from sysobjects where xtype= ' PK ' and Parent_obj=c.id and name in (
Select name from sysindexes where Indid in (
Select Indid from Sysindexkeys where id = c.id and colid=c.colid)))
When the ' 1 ' then ' √ ' else ' end as ' is the primary key '
, Case (ColumnProperty (c.id,c.name, ' isidentity ')) when ' 1 ' then ' √ ' else ' end as ' auto Grow '
, IsNull (Etp.value, ') as ' field description '
From syscolumns C
INNER JOIN systypes t on c.xusertype = T.xusertype
Left join sys.extended_properties ETP on etp.major_id = c.id and etp.minor_id = c.colid and etp.name = ' ms_description '
Left join syscomments CM on C.cdefault=cm.id
Left join sysobjects obj on c.id=obj.id
where c.id = object_id (' Table name ')
Query table structure