in

code for eternity !!!

community website for .net freaks ;-)

Technology

Finding Database Size using sp_spaceused Stored Procedure

We can use the sp_spaceused stored procedure to find out exactly how much disk space is currently being used by a database. If we simply execute this stored procedure without passing any parameters, it returns the following 2 result sets:

Result Set 1:

database_name: Name of the current database.
database_size: Size of the current database in megabytes. database_size includes both data and log files.
unallocated space: Space in the database that has not been reserved for database objects.

Result Set 2:

reserved: Total amount of space allocated by objects in the database.
data: Total amount of space used by data.
index_size: Total amount of space used by indexes.
unused: Total amount of space reserved for objects in the database, but not yet used.

code for etetnity !!! is hosted with GoDaddy Shared Hosting Plan which only allows upto 200 MB of database disk space which is really very limited and Community Server can reach this limit in no time. Therefore I have to keep monitoring the database disk space usage regularly. However, since GoDaddy does not provide Remote Desktop or Enterprise Manager / Management Studio access to the database server, the only way to know this is by executing the sp_spaceused stored procedure through GoDaddy's web based Query Analyzer or through a custom built ASP.NET web page which executes this stored procedure using ADO.NET. You can use the same technique if you face similar restrictions by your hosting provider.

For more info on the sp_spaceused stored procedure, click here.

Cheers,
Raj

~~~ CODING FOR ETERNITY !!! ~~~


I would really appreciate votes / kicks for this blog post if you found it useful ;-)

  kick it on DotNetKicks.com     Receive Email Updates


Comments

 

Joe Webb said:

Good practical example. Thanks for sharing, Raj!

Cheers!

Joe

February 19, 2008 10:23 AM
 

raj said:

Hi Joe,

Thanks for your kind words :-)

Cheers,
Raj

~~~ CODING FOR ETERNITY !!! ~~~

February 23, 2008 6:10 AM

Leave a Comment

(required)  
(optional)
(required)  
Add


StopGlobalWarming.org  
Powered by Community Server (Non-Commercial Edition), by Telligent Systems