In this tutorial you will learn how to get the size of SQL Server database and its tables. It is a good approach to check the size of your database routine wise and then performed appropriate action with respect to analysis. In the following example we will find the size of a table.
Get the size of SQL Server Database and TablesGetting the size of table
EXEC SP_SPACEUSED 'YOUR TABLE NAME'
MS SQL Server contains a built-in system store procedure named SP_SPACEUSED. This store procedure is very handy. Using this store procedure you can find the size of the database as well as the size of the any table you want. When you execute the SP_SPACEUSED with table name as a parameter then it will provide you following information of that table.
The following example shows how to get the size of all tables from database
EXEC sp_MSforeachtable @command1="EXEC sp_spaceused '?'"
Getting the size of ms sql server database
To find the size of ms sql server database, you have to execute the SP_SPACEUSED store procedure without any parameter. It will automatically provides you the size of the database that you will be using.
I love your feedback