sql2000 数据字典查询代码

参考:http://blog.csdn.net/topcool/archive/2005/01/22/263553.aspx

select object_name (id) as 表名
,c.name
as 字段名
,t.name数据类型
,c.prec
as 长度
from syscolumnsc
inner join
systypest
on c.xusertype = t.xusertype
where object_name (id) = ' Table ' -- 把Table改成你的表名即可
go

等下写个数据字典生成器,然后就可以选中数据库,为里面的每个表都生成字典并写到excel文件中.呵呵.

另一个更强的.

SELECT 表名 = case when a.colorder = 1 then d.name else '' end ,
字段序号
= a.colorder,
字段名
= a.name,
标识
= case when COLUMNPROPERTY (a.id,a.name, ' IsIdentity ' ) = 1 then ' ' else '' end ,
主键
= 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 = a.id AND colid = a.colid)))
then ' ' else '' end ,
类型
= b.name,
-- 占用字节数=a.length,
长度 = COLUMNPROPERTY (a.id,a.name, ' PRECISION ' ),
小数位数
= isnull ( COLUMNPROPERTY (a.id,a.name, ' Scale ' ), 0 ),
允许空
= case when a.isnullable = 1 then ' ' else '' end ,
默认值
= isnull (e. text , '' ),
字段说明
= isnull (g. [ value ] , '' )
FROM syscolumnsa left join systypesb on a.xtype = b.xusertype inner join sysobjectsd on a.id = d.id
and d.xtype = ' U ' and d.name <> ' dtproperties '
left join syscommentse on a.cdefault = e.id left join syspropertiesg on a.id = g.id
and a.colid = g.smallid
order by a.id,a.colorder

还有这位老兄的查看每个表使用的大小代码

exec sp_spaceusedlibbooks

就可以查出来了

比较详细,有行数,表保留的空间总量,数据所使用的空间量,表中的索引所使用的空间量,表中未用的空间量

不加参数,可以查到数据库的使用量:

exec sp_spaceused

你可能感兴趣的:(C++,c,Excel,C#,Go)