------Export Table Structure statements
1. Execute the following query
SELECT
Table name = Case If A.colorder=1 then d.name else ' end,
Table Description = case when a.colorder=1 then IsNull (F.value, ') Else ' end,
Field ordinal = A.colorder,
Field name = A.name,
Identification = 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 ' √ ' E LSE ' END,
Type = B.name,
Number of bytes occupied = a.length,
Length = ColumnProperty (a.id,a.name, ' PRECISION '),
Number of decimal digits = IsNull (ColumnProperty (a.id,a.name, ' scale '), 0),
Allow NULL = case time a.isnullable=1 Then ' √ ' Else ' end,
Default value = 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 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= ' b_table '--if only the specified table is queried, add this condition
ORDER BY
A.id,a.colorder
2. Copy to Excel.
3. Copy from Excel to Word to form a document.
SQL Server Export table structure to Word