mssqlserver 查询数据库表结构语句

时间:2021-10-12 04:31:46

查询指定表结构的表名、列名、类型、说明、字段长度

select
o.name as tableName,c.name as columnName,t.name as columnType,p.value as columnDescription,c.prec
from  sysobjects o left join syscolumns c  on o.id=c.id
left join sys.extended_properties p on p.major_id=c.id and p.minor_id=c.colid and p.name='MS_Description'
left join systypes t on c.xusertype=t.xusertype
where o.type='u'
and o.name='WordFiles'

较为详细的查看表结构:

sp_columns 'WordFiles'