SELECT
(Case when a. colorder = 1 then d. name else ''end) Table name,
A. Serial number of the colorder field,
A. name field name,
(Case when COLUMNPROPERTY (a. id, a. name, 'isidentity ') = 1 then' √ 'else' end) id,
(Case when (SELECT count (*)
FROM sysobjects
WHERE (name in (SELECT name
FROM sysindexes
WHERE (id = a. id) AND (indid in (SELECT indid
FROM sysindexkeys
WHERE (id = a. id) AND (colid in (SELECT colid
FROM syscolumns
WHERE (id = a. id) AND (name = a. name)
)
)
)
)
)
) AND (xtype = 'pk ')
)> 0 then' √ 'else' end) primary key,
B. name type,
A. length occupies the number of bytes,
COLUMNPROPERTY (a. id, a. name, 'precision ') as length,
Isnull (COLUMNPROPERTY (a. id, a. name, 'Scale'), 0) as decimal places,
(Case when a. isnullable = 1 then '√ 'else'' end) Allow null,
Isnull (e. text, '') default value,
Isnull (g. [value], '') AS field description
FROM syscolumns
Left join policypes 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
Order by a. id, a. colorder