日期:2014-05-17 浏览次数:20489 次
SELECT top 50 OBJ.name AS ObjName
,STAT.row_count AS [RowCount]
,sum(STAT.used_page_count )* 8/1024 AS UsedSizeMB
FROM sys.partitions AS PART
INNER JOIN sys.dm_db_partition_stats AS STAT
ON PART.partition_id = STAT.partition_id
AND PART.partition_number = STAT.partition_number
INNER JOIN sys.objects AS OBJ
ON STAT.object_id = OBJ.object_id
INNER JOIN sys.schemas AS SCH
ON OBJ.schema_id = SCH.schema_id
INNER JOIN sys.indexes AS INDX
ON STAT.object_id = INDX.object_id
AND STAT.index_id = INDX.index_id
group by OBJ.name ,STAT.row_count
ORDER BY UsedSizeMB desc
CREATE TABLE test1 (NAME VARCHAR(30),[ROWS] bigINT,reserved VARCHAR(30),[data] VARCHAR(30),index_size VARCHAR(30),unused VARCHAR(30))
go
INSERT INTO test1(name,[rows],reserved,data,index_size,unused)
EXECUTE sp_msforeachtable 'sp_spaceused [?] '