In this example, you will see how to find the size of table from a database. SQL server gives you build in system store procedure named SP_SPACEUSED. Following information will be shown on the screen when you will run SP_SPACEUSED system store procedure.
- Name of the table
- Number of rows in the table
- Disk space reserved size
- Data size of table
- Table indexes size
- Table unused size
Syntax:
EXEC SP_SPACEUSED 'TABLE NAME'
Example 1
This example shows you how to get the SQL Server database table size.
EXEC SP_SPACEUSED 'be_postcomments’
Output

Example 2
This example shows you how to get the size of a database
EXEC SP_SPACEUSED
Output

Example 3
This example shows you how to get the all tables size from database
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
