SELECT
Table name =case when a.colorder=1 then D.name else ' end,
Table shows =case when a.colorder=1 then IsNull (F.value, ') Else ' end,
Field Ordinal =a.colorder,
Field name =a.name,
Identify =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 name in (
SELECT name from sysindexes WHERE indid in (
SELECT indid from Sysindexkeys WHERE id = a.id and colid=a.colid
)) and then ' √ ' Else ' end,
Type =b.name,
Takes up the number of bytes =a.length,
Length =columnproperty (a.id,a.name, ' PRECISION '),
Number of decimal digits =isnull (columnproperty (a.id,a.name, ' scale '), 0),
Allow empty =case when a.isnullable=1 then ' √ ' Else ' end,
The default value is =isnull (E.text, "),
Field Description =isnull (G.[value], ")
From Syscolumns A
Left join Systypes 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 joins 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= ' Cj_products_bak '--if only the specified table is queried, add this condition
ORDER BY A.id,a.colorder
Reading a database table field