How to get table size in SQL Server

As a database administrator working with SQL Server, I’ve often needed to check the size of tables in my databases. Whether you’re managing the storage or optimizing the performance, knowing how to get table size in SQL Server is an essential skill. In this post, I’ll walk you through various approaches I have identified to retrieve this information, complete with examples and scenarios.

Approach-1 Using SQL Server Management Studio

Follow the below steps.

1. Right-click on the Database name –> Reports –> Standard Reports –> Select Disk Usage by Table option.

How to get table size in SQL Server

Now, you can see the sizes of all the tables from my SQL server database below.

how to get the size of table in sql server

Check out How To Check If Table Exists In SQL Server

Approach-2 Using sp_MSForEachTable

We can execute the query below to get the size of the tables on your SQL server database.

exec sp_MSForEachTable 'exec sp_spaceused [?]';

After executing the above query, I got the expected output, as shown in the screenshot below.

how to get the table size in sql server

Check out How To Find Column Name In Table SQL Server

Approach-3 Using sp_spaceused

We can also execute the below query, where you need to specify the table name to see the size. Below ProductNew is the name of the table.

exec sp_spaceused [ProductNew]

After executing the above query, I got the expected output below.

sql server get table size

Conclusion

Checking the table size is crucial for effective database management. Whether you prefer the GUI approach with SQL Server Management Studio, SQL queries, or check with sp_spaceused as discussed in this article.

You may also like following the articles below.