【Sql】查询数据库表基本信息

SELECT a.name as '字段名',c.name '类型',e.value as '字段说明',sm.text as '默认值' FROM syscolumns a
left join systypes b on a.xusertype=b.xusertype
left join systypes c on a.xtype = c.xusertype
inner join sysobjects d on a.id=d.id and d.xtype='U'
left join syscomments sm on a.cdefault=sm.id
left join sys.extended_properties e on a.id = e.major_id and a.colid = e.minor_id and
e.name='MS_Description' where d.name='tablename'

你可能感兴趣的:(【Sql】查询数据库表基本信息)