Skip to content
Home » How to get the size of table in SQL

How to get the size of table in SQL

There are multiple ways to get the size of table in SQL Server. Lets take a look on them one by one.

Using sp_spaceused system stored procedure

Get table size using sp_spaceused system stored procedure which returns the number of rows, disk space reserved, and disk space used by a table.



Lets see the size of table ProductDetails.

sp_spaceused 'ProductDetails'

Get the size of all tables in SQL Server

To get the size of all tables in SQL Server you can use stored procedure sp_MSforeachtable, it allows us to run same T- SQL query against each and every table in a single database.

Lets execute the below T-SQL, and you will see it returns the size of all tables in a database Dev_Db.

sp_msforeachtable 'EXEC sp_spaceused [?]'





 

Using Microsoft SQL Server Object Explorer

You can see the table size using object explorer, Go to Object explorer then right click on table as shown below.





After that, a table properties window opens. Now just click on Storage tab and on the right side under General section you will see the table size information as shown below.

 

Also Read..

SQL Server Basics

SQL Server Advance

SQL Server Interview Q & A

 

Loading

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.