728x90
SELECT 
    t.NAME AS [테이블 이름],
    p.[rows] AS [행 수],
    SUM(a.total_pages) * 8 AS [총 크기 (KB)],
    SUM(a.used_pages) * 8 AS [사용 크기 (KB)],
    (SUM(a.total_pages) - SUM(a.used_pages)) * 8 AS [여유 크기 (KB)]
FROM 
    sys.tables AS t
INNER JOIN      
    sys.indexes AS i ON t.object_id = i.object_id
INNER JOIN 
    sys.partitions AS p ON i.object_id = p.object_id AND i.index_id = p.index_id
INNER JOIN 
    sys.allocation_units AS a ON p.partition_id = a.container_id
WHERE 
    t.NAME = 'DO_FILE'  -- 조회할 테이블 이름으로 변경합니다.
GROUP BY 
    t.NAME, p.[rows]

+ Recent posts