Herkese merhaba,
Bu kısımda SQL Server’da tablo ve indekslerin kapladığı yeri hesaplama kodları olacak.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
SELECT s.name AS SchemaName , t.name AS TableName , p.rows AS RowCounts , SUM(a.total_pages) * 8 AS TotalSpaceKB , SUM(a.used_pages) * 8 AS UsedSpaceKB , ( SUM(a.total_pages) - SUM(a.used_pages) ) * 8 AS UnusedSpaceKB FROM sys.tables t INNER JOIN sys.schemas s ON s.schema_id = t.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%' -- filter out system tables for diagramming AND t.is_ms_shipped = 0 AND i.object_id > 255 GROUP BY t.name , s.name , p.rows ORDER BY s.name , t.name |
