how much space does sql server take per row

Solutions on MaxInterview for how much space does sql server take per row by the best coders in the world

showing results for - "how much space does sql server take per row"
Cece
07 Apr 2017
1SELECT 
2    TableName = t.NAME,
3    SchemaName = s.Name,
4    [RowCount] = p.rows,
5    TotalSpaceMB = CONVERT(DECIMAL(18,2), SUM(a.total_pages) * 8 / 1024.0), 
6    UsedSpaceMB = CONVERT(DECIMAL(18,2), SUM(a.used_pages) * 8 / 1024.0),
7    UnusedSpaceMB = CONVERT(DECIMAL(18,2), (SUM(a.total_pages) - SUM(a.used_pages)) * 8 / 1024.0)
8FROM 
9    sys.tables t
10    INNER JOIN sys.indexes i ON t.OBJECT_ID = i.object_id
11    INNER JOIN sys.partitions p ON i.object_id = p.OBJECT_ID AND i.index_id = p.index_id
12    INNER JOIN sys.allocation_units a ON p.partition_id = a.container_id
13    LEFT OUTER JOIN sys.schemas s ON t.schema_id = s.schema_id
14WHERE 
15    t.NAME NOT LIKE 'dt%' 
16    AND t.is_ms_shipped = 0
17    AND i.OBJECT_ID > 255 
18GROUP BY 
19    t.Name, 
20    s.Name, 
21    p.Rows
22ORDER BY 
23    TotalSpaceMB DESC
24
similar questions