邹建写的
AbateTime 1 ProductNo int 10 0 4 √ √
2 AbateDays int 10 0 4
4 NextDays int 10 0 4 √ (0)
5 ifauto int 10 0 4 √ (0)
AdvManage 1 No int 10 0 4 √
select
case
when
c.colid
=
1
then
o.name
else
''
end
表名,
--
得到表名,重复的表名不显示
c.colid顺序,
c.name字段名,
t.name字段类型,
columnproperty (c.id,c.name, ' PRECISION ' )字段长度,
isnull (c.Scale, '' )小数位,
c.length占用字节,
case when c.isnullable = 1 then ' √ ' else '' end 可为空,
case when c.colid in ( select ik.colid
from sysindexesi,Sysindexkeysik,sysobjectsoo
where i.id = ik.id and i.indid = ik.indid
and i.name = oo.name and oo.xtype = ' PK ' -- 主键
and o.id = i.id
) then ' √ ' else '' end 主键,
case when c.colid in ( select ik.colid
from sysindexesi,Sysindexkeysik
where i.id = ik.id and i.indid = ik.indid
and o.id = i.id and i.indid = 1 -- 聚类索引
) then ' √ ' else '' end 聚类索引,
case when columnproperty (c.id,c.name, ' IsIdentity ' ) = 1 then ' √ ' else '' end 自增长,
isnull (m. text , '' )默认值
from sysobjectso,syscolumnsc,systypest,syscommentsm
where o.xtype = ' U '
and o.id = c.id
and c.xtype = t.xtype
and c.cdefault *= m.id
order by o.name,c.colid
c.colid顺序,
c.name字段名,
t.name字段类型,
columnproperty (c.id,c.name, ' PRECISION ' )字段长度,
isnull (c.Scale, '' )小数位,
c.length占用字节,
case when c.isnullable = 1 then ' √ ' else '' end 可为空,
case when c.colid in ( select ik.colid
from sysindexesi,Sysindexkeysik,sysobjectsoo
where i.id = ik.id and i.indid = ik.indid
and i.name = oo.name and oo.xtype = ' PK ' -- 主键
and o.id = i.id
) then ' √ ' else '' end 主键,
case when c.colid in ( select ik.colid
from sysindexesi,Sysindexkeysik
where i.id = ik.id and i.indid = ik.indid
and o.id = i.id and i.indid = 1 -- 聚类索引
) then ' √ ' else '' end 聚类索引,
case when columnproperty (c.id,c.name, ' IsIdentity ' ) = 1 then ' √ ' else '' end 自增长,
isnull (m. text , '' )默认值
from sysobjectso,syscolumnsc,systypest,syscommentsm
where o.xtype = ' U '
and o.id = c.id
and c.xtype = t.xtype
and c.cdefault *= m.id
order by o.name,c.colid
AbateTime 1 ProductNo int 10 0 4 √ √
2 AbateDays int 10 0 4
4 NextDays int 10 0 4 √ (0)
5 ifauto int 10 0 4 √ (0)
AdvManage 1 No int 10 0 4 √