select id, reserved , dpages , minlen ,rows into #sysindexes from sysindexes WITH(NOLOCK) WHERE indid IN (0, 1) select * into #table from sys.tables select* into #schemas from sys.schemas select distinct s.name 架构,t.name 表名, 8*b.reserved/1024 保留, rtrim(8*b.dpages) [占用内存(kb)], CAST(CAST(rtrim(8*b.dpages) AS DECIMAL(32,2) )/1024 AS VARCHAR(500)) [占用内存(MB)], CAST(CAST(rtrim(8*b.dpages) AS DECIMAL(32,2) )/1024/1024 AS VARCHAR(500)) [占用内存(GB)] , CAST(CAST(rtrim(8*b.dpages) AS DECIMAL(32,2) )/1024/1024/1024 AS VARCHAR(500)) [占用内存(TB)], 8*(b.reserved-b.dpages)/1024 unused, 8*b.dpages/1024-b.rows/1024*b.minlen/1024 free, b.rows 数量 from #table t INNER JOIN #sysindexes AS b ON t.OBJECT_ID = b.id INNER JOIN #schemas s ON t.schema_id = s.schema_id order by b.rows desc drop table #table drop table #sysindexes drop table #schemas
posted on
浙公网安备 33010602011771号