标签:
如何查看表占用空间大小
--定义表变量
Create TABLE T
(
[name] VARCHAR(max),
[rows] INT,
reserved VARCHAR(max),
data_size VARCHAR(max),
index_size VARCHAR(max),
unused VARCHAR(max)
)
--将表占用情况存放到表变量
INSERT INTO T
EXEC sp_MSforeachtable "exec sp_spaceused ‘?‘"
SELECT [name],[rows],reserved,data_size,index_size,unused,
CAST(REPLACE(reserved,‘KB‘,‘‘) AS INT)/1024 as reserved_MB,
CAST(REPLACE([data_size],‘KB‘,‘‘) AS INT)/1024 as data_size_MB,
CAST(REPLACE([index_size],‘KB‘,‘‘) AS INT)/1024 as index_size_MB,
CAST(REPLACE([unused],‘KB‘,‘‘) AS INT)/1024 as unused_MB
FROM T
order by CAST(REPLACE(reserved,‘KB‘,‘‘) AS INT) desc
如何查看表占用空间大小
标签:
原文地址:http://www.cnblogs.com/szlixin/p/4312334.html