How do you see the size of every table in SQL Server?
A DB on my test server grew, and I needed to know which tables took the space. SQL Server has no single command for SQL Server table size across every table, so I looked up how to check table size in SQL Server for all of them at once.
There are three ways:
- My favorite: one query for every table (fastest): use when I want all tables ranked, largest first.
sp_spaceused: use when I need just one table.- The SSMS report: use when I'd rather click than type.
Two more sections: few rows but a lot of data and index size that looks too high. I made test data so you can try these: jump to it. I ran this on SQL 2022.
SQL Server table size for every table
This is my favorite. It adds up the pages in sys.dm_db_partition_stats for each table and converts them to MB. A page is 8 KB.
SELECT s.name AS schema_name,
t.name AS table_name,
SUM(CASE WHEN ps.index_id IN (0,1) THEN ps.row_count ELSE 0 END) AS row_count,
CAST(SUM(ps.reserved_page_count) * 8 / 1024.0 AS decimal(18,2)) AS reserved_mb,
CAST(SUM(CASE WHEN ps.index_id IN (0,1)
THEN ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count
ELSE 0 END) * 8 / 1024.0 AS decimal(18,2)) AS data_mb,
CAST((SUM(ps.used_page_count)
- SUM(CASE WHEN ps.index_id IN (0,1)
THEN ps.in_row_data_page_count + ps.lob_used_page_count + ps.row_overflow_used_page_count
ELSE 0 END)) * 8 / 1024.0 AS decimal(18,2)) AS index_mb,
CAST((SUM(ps.reserved_page_count) - SUM(ps.used_page_count)) * 8 / 1024.0 AS decimal(18,2)) AS unused_mb
FROM sys.tables t
JOIN sys.schemas s ON s.schema_id = t.schema_id
JOIN sys.dm_db_partition_stats ps ON ps.object_id = t.object_id
GROUP BY s.name, t.name
ORDER BY reserved_mb DESC;schema_name | table_name | row_count | reserved_mb | data_mb | index_mb | unused_mb |
|---|---|---|---|---|---|---|
| dbo | Documents | 2000 | 250.33 | 250.13 | .02 | .19 |
| dbo | Orders | 200000 | 19.90 | 11.52 | 7.85 | .52 |
| dbo | OrderLog | 100000 | 11.38 | 11.33 | .01 | .05 |
| dbo | Lookup | 3 | .07 | .01 | .01 | .05 |
The Orders row matches the sp_spaceused result in the next section: 19.90 MB is 20,376 KB. reserved_mb is the size on disk, so sort by it. Add TOP (20) after SELECT if the DB has thousands of tables. Add WHERE s.name = N'dbo' for one schema.
You need VIEW DATABASE STATE and VIEW DEFINITION to run it. On SQL 2022 and later, Microsoft lists VIEW DATABASE PERFORMANCE STATE and VIEW SECURITY DEFINITION instead.
Size of one table
Pass the table name:
EXEC sp_spaceused N'dbo.Orders';name | rows | reserved | data | index_size | unused |
|---|---|---|---|---|---|
| Orders | 200000 | 20376 KB | 11800 KB | 8040 KB | 536 KB |
Run it again for another table:
EXEC sp_spaceused N'dbo.Documents';name | rows | reserved | data | index_size | unused |
|---|---|---|---|---|---|
| Documents | 2000 | 256336 KB | 256128 KB | 16 KB | 192 KB |
Sizes come back in KB. For Orders, reserved (20,376 KB) is data plus index plus unused: 11,800 + 8,040 + 536. Microsoft describes each column on its sp_spaceused page.

Skip the table name to get the whole DB:
EXEC sp_spaceused;database_name | database_size | unallocated space |
|---|---|---|
| t_sql_server_table_size | 656.00 MB | 54.20 MB |
reserved | data | index_size | unused |
|---|---|---|---|
| 280368 KB | 269080 KB | 9504 KB | 1784 KB |
It checks one table at a time and skips the schema name. For all tables, use the query above.
Use the SSMS disk usage report
SSMS has a built-in disk usage report for each DB.
It is a quick picture. I use the script to filter, sort or keep numbers.
Few rows, huge table
Rows and MB tell different stories. Orders has 200,000 rows and takes 19.90 MB. Documents has 2,000 rows and takes 250.33 MB. A row count alone misses this.

Documents has far fewer rows than Orders and is over ten times larger.Documents has a big nvarchar(max) column. This splits its pages into in-row and LOB (large object) pages:
SELECT OBJECT_NAME(object_id) AS table_name,
CAST(SUM(in_row_data_page_count) * 8 / 1024.0 AS decimal(18,2)) AS in_row_mb,
CAST(SUM(lob_used_page_count) * 8 / 1024.0 AS decimal(18,2)) AS lob_mb
FROM sys.dm_db_partition_stats
WHERE object_id = OBJECT_ID('dbo.Documents') AND index_id IN (0,1)
GROUP BY object_id;table_name | in_row_mb | lob_mb |
|---|---|---|
| Documents | .12 | 250.01 |
Almost all 250 MB is LOB data. A query that sums only in_row_data_page_count shows 0.12 MB. My first query adds LOB and row-overflow pages, so it counts them.
Index size looks too high
In the first query, heap or clustered index data counts as data_mb. Every other index counts as index_mb. To see each index, group by index:
SELECT OBJECT_NAME(ps.object_id) AS table_name,
ISNULL(i.name, '(heap)') AS index_name,
i.type_desc,
SUM(ps.row_count) AS row_count,
CAST(SUM(ps.reserved_page_count) * 8 / 1024.0 AS decimal(18,2)) AS reserved_mb
FROM sys.dm_db_partition_stats ps
JOIN sys.indexes i ON i.object_id = ps.object_id AND i.index_id = ps.index_id
WHERE ps.object_id IN (OBJECT_ID('dbo.Orders'), OBJECT_ID('dbo.OrderLog'))
GROUP BY ps.object_id, i.name, i.type_desc
ORDER BY table_name, reserved_mb DESC;table_name | index_name | type_desc | row_count | reserved_mb |
|---|---|---|---|---|
| OrderLog | (heap) | HEAP | 100000 | 11.38 |
| Orders | PK__Orders__C3905BAF6A6527C7 | CLUSTERED | 200000 | 11.76 |
| Orders | IX_Orders_Customer | NONCLUSTERED | 200000 | 4.45 |
| Orders | IX_Orders_Date | NONCLUSTERED | 200000 | 3.70 |
OrderLog is a heap with no indexes, so all 11.38 MB is data. Orders has a clustered primary key and two nonclustered indexes. Those two take 8.15 MB, more than half the table's data. A note I left myself in 2015 says sp_spaceused gives all indexes combined. That is why I run this query for index size.
Gotcha: the numbers look wrong or stale
Check these before you trust the table size in SQL Server:
- Sort by
reserved_mb, notdata_mb. It ranks what each table takes on disk. - Compare one table with
sp_spaceused. They should agree, asOrdersdid. - Run
EXEC sp_spaceused @updateusage = N'TRUE'. Microsoft says it fixes stale usage info, can run long on large objects and needsdb_owner. - After you drop or truncate a large table, numbers may lag. Microsoft says the engine frees the pages later.
row_counthere is approximate, per Microsoft's partition stats page. UseSELECT COUNT(*)for an exact number.
Try it on my test data
Run this in a test DB to repeat my results. It loads 200,000, 100,000, 2,000 and 3 rows.
CREATE TABLE dbo.Orders (OrderID int IDENTITY(1,1) PRIMARY KEY, CustomerID int NOT NULL, OrderDate datetime2 NOT NULL, Status char(1) NOT NULL, Note varchar(100) NULL);
CREATE INDEX IX_Orders_Customer ON dbo.Orders (CustomerID) INCLUDE (OrderDate);
CREATE INDEX IX_Orders_Date ON dbo.Orders (OrderDate);
CREATE TABLE dbo.OrderLog (LogID int NOT NULL, Msg varchar(200) NOT NULL);
CREATE TABLE dbo.Documents (DocID int IDENTITY(1,1) PRIMARY KEY, Title nvarchar(100) NOT NULL, Body nvarchar(max) NOT NULL);
CREATE TABLE dbo.Lookup (Code int PRIMARY KEY, Label varchar(20) NOT NULL);
GO
;WITH n AS (SELECT TOP (200000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS i FROM sys.all_objects a CROSS JOIN sys.all_objects b)
INSERT dbo.Orders (CustomerID, OrderDate, Status, Note)
SELECT i % 5000, DATEADD(minute, i, '2025-01-01'), 'N', REPLICATE('x', i % 60) FROM n;
;WITH n AS (SELECT TOP (100000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS i FROM sys.all_objects a CROSS JOIN sys.all_objects b)
INSERT dbo.OrderLog (LogID, Msg) SELECT i, REPLICATE('y', 100) FROM n;
;WITH n AS (SELECT TOP (2000) ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS i FROM sys.all_objects)
INSERT dbo.Documents (Title, Body) SELECT CONCAT(N'Doc ', i), REPLICATE(CONVERT(nvarchar(max), N'lorem ipsum '), 5000) FROM n;
INSERT dbo.Lookup VALUES (1,'New'),(2,'Paid'),(3,'Shipped');


