询SQL Server中表占用的空间方法<!-- <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"><rdf:Description rdf:about="http://databaseadmin.itpub.net/post/20809/145532" dc:identifier="http://databaseadmin.itpub.net/post/20809/145532" dc:title="查询SQL Server中表占用的空间方法" trackback:ping="http://blog.itpub.net//trackback.php?id=145532"/></rdf:RDF> -->
databaseadmin | 17 七月, 2006 04:10
如何来查询SQL Server中数据库的各个表所占用的空间?
下面来介绍一下两种用来方法。
方法1:
select object_name(id) tablename,
8
*
reserved
/
1024
reserved,rtrim(
8
*
dpages
/
1024
)
+
'
Mb
'
used,
8
*
(reserved
-
dpages)
/
1024
unused,
8
*
dpages
/
1024
-
rows
/
1024
*
minlen
/
1024
free, rows,
*
from sysindexes where indid
=
1
order by reserved desc
方法2:
EXEC sp_spaceused 'phb' --phb是表名 by yl
来自:http://databaseadmin.itpub.net/post/20809/145532/