SELECT
Table name =case when a.colorder=1 then D.name else ' end,
Serial number =a.colorder,
Column name =a.name,
Data type =b.name,
Length =columnproperty (a.id,a.name, ' PRECISION '),
Decimal Place =isnull (ColumnProperty (a.id,a.name, ' scale '), 0),
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 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 ' Y ' Else ' end,
Foreign key = ' ',
Allow empty =case when a.isnullable=1 then ' is ' else ' no ' end,
The default value is =isnull (E.text, "),
PB Annotated =isnull (P.pbc_cmnt, "),
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
Left join Pbcatcol p on A.name=p.pbc_cnam and D.name=p.pbc_tnam
where d.name like ' a_employee_mi '--If you only query the specified table, add this condition
ORDER BY A.id,a.colorder
SQL system functions take table basic information