select sysobjects.name as [table], sysproperties.[value] as 表说明,
syscolumns.name as field, properties.[value] as 字段说明, systypes.name as type,
syscolumns.length, isnull(columnproperty(syscolumns.id, syscolumns.name,
'scale'), 0) as 小数位数, syscolumns.isnullable as isnull,
case when syscomments.text is null
then '' else syscomments.text end as [default],
case when columnproperty(syscolumns.id, syscolumns.name, 'isidentity')
= 1 then '√' else '' end as 标识, 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 = syscolumns.id and colid = syscolumns.colid)))
then '√' else '' end as 主键
from syscolumns inner join
sysobjects on sysobjects.id = syscolumns.id inner join
systypes on syscolumns.xtype = systypes.xtype left outer join
sysproperties properties on syscolumns.id = properties.id and
syscolumns.colid = properties.smallid left outer join
sysproperties on sysobjects.id = sysproperties.id and
sysproperties.smallid = 0 left outer join
syscomments on syscolumns.cdefault = syscomments.id
where (sysobjects.xtype = 'u')
新闻热点
疑难解答