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 No. = A. colorder,
Field name = A. Name,
Id = case when columnproperty (A. ID, A. Name, 'isidentity ') = 1 then' √ 'else' end,
Primary Key = case when exists (select 1 from sysobjects where xtype = 'pk' and parent_obj = A. ID and name in (
Select name from sysindexes where indid in (select indid from sysindexkeys where id = A. ID and colid = A. colid) Then '√ 'else' 'end,
Type = B. Name,
Bytes occupied = A. length,
Length = columnproperty (A. ID, A. Name, 'precision '),
Decimal places = isnull (columnproperty (A. ID, A. Name, 'Scale'), 0 ),
Allow null = case when a. isnullable = 1 then '√ 'else' 'end,
Default Value = isnull (E. Text ,''),
Field description = isnull (G. [value], '')
From
Syscolumns
Left join
Policypes B
On
A. xusertype = 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
SYS. extended_properties g
On
A. ID = G. major_id and A. colid = G. minor_id
Left join
SYS. extended_properties F
On
D. id = f. major_id and F. minor_id = 0
Where
D. Name = 'spp _ p_sgl '-- this condition is added if only the specified table is queried.
Order
A. ID, A. colorder