블로그 이미지
bedbmsguru

Notice

Recent Comment

Recent Trackback

Archive

calendar

            1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31          
  • 27,179total
  • 0today
  • 8yesterday
2016.04.26 16:05 SQL SERVER

SELECT
    s.NAME AS SchemaName, 
    t.NAME AS TableName,
    p.rows AS RowCounts,
    SUM(a .total_pages) * 8 /1024 AS TotalSpaceMB,  
    SUM(a .used_pages) * 8 /1024 AS UsedSpaceMB,  
    (SUM( a.total_pages ) - SUM( a.used_pages )) * 8 /1024 AS UnusedSpaceMB
FROM  sys .tables t
INNER JOIN sys. Schemas s ON t.schema_id = s.schema_id
INNER JOIN sys. indexes i ON t.OBJECT_ID = i.object_id
INNER JOIN sys. partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
INNER JOIN sys. allocation_units a ON p.partition_id = a.container_id
WHERE 
    t.NAME NOT LIKE 'dt%'  
    AND t .is_ms_shipped = 0
    AND i .OBJECT_ID > 255 
GROUP BY
 s. Name, 
    t.Name ,
    p.[Rows]
ORDER BY  
 TotalSpaceMB desc

저작자 표시
신고
posted by bedbmsguru

티스토리 툴바