■ 테이블별 사용 용량을 구하는 방법을 보여준다.
▶ 예제 코드 (SQL)
1 2 3 4 5 6 7 8 9 10 11 12 |
SELECT MAX(B.name) AS TableName ,CAST((SUM(A.reserved) * 8192.0 / 1024 ) AS NUMERIC(18, 0)) AS TableSizeKB ,CAST((SUM(A.reserved) * 8192.0 / 1048576) AS NUMERIC(18, 0)) AS TableSizeMB FROM sysindexes A INNER JOIN sysobjects B ON B.id = A.id WHERE A.indid in (0, 1, 255) AND B.xtype = 'U' GROUP BY A.id ORDER BY SUM(a.reserved) DESC; |