SELECT
Table name = Case When a.colorder = 1 Then D.Name Else '' end,
Table Description = Case When a.colorder = 1 Then ISNULL (F.Value, '') Else '' end,
Field serial number = a.colorder,
Field name = a.Name,
Logo = Case When ColumnProperty (A.ID, A.NAME, 'ISIDENTITY') = 1 TEN '√'lse' 'end,
Primary key = Case When exists (SELECT 1 from sysobjects where xtype = 'pk' and name in)
Select Name from sysindexes where indid in
Select Indid from sysindexkeys where id = a.id and color = a.colid
))) The '√' else '' end,
Type = B.Name,
Number of bytes = a.length,
Length = ColumnProperty (A.ID, A.Name, 'Precision'),
Digital digits = ISNULL (ColumnProperty (A.ID, A.NAME, 'Scale'), 0),
Allow empty = Case When a.isnullable = 1 Then '√'lse' 'End,
Default = Isnull (E.Text, ''),
Field Description = ISNULL (g. [Value], '')
From syscolumns a
Left join systemypes b on a.xtype = B.xUsertype
Inner Join Sysobjects D on A.Id = D.ID and D.XTYPE = 'u' and D.Name <> DTPROPERTIES '
Left join syscomments e on a.cdefault = E.ID
Left join sysproperties g on a.id = g.id and a.colid = g.smallid
LEFT JOIN SYSPROPERTIES F on D.ID = f.id and f.smallid = 0
--where d.name = 'To query table' - If you only query the specified table, add this condition
Order by a.id, a.colorder