in

Citrus-Lime Blog

Information on Citrus-Lime including our eCommerce and Retail Projects

CoolSQL

Find SQL Server database and log file size with stored procedure

sp_SDS is a stored procedure in the master database on CITRMANSQL2. It can be used to calculate SQL database and log file size.. It can take 4 parameters breifly described below.

Variable Description
@TargetDatabase The database we want to size
@Level How detailed the report should be, either at the database level or at the individual database file level
@UpdateUsage The default value of 0 means we do not wish to run "DBCC UPDATEUSAGE"
@Unit indicates what measurement the report should be in, namely KB, MB or GB. If it's not specified, the measurement used is megabytes.
 

Typical scenario for simple useage with default parameters

USE master
EXEC dbo.sp_SDS

Result of running sp_SDS with no input parameters on a testing SQL Server 2005.

The first column "Weight (%)" calculates the percentage of total database size that a given database takes. For example, AdventureWorks is 469.94 MB in total, divided by the grand total of 20,404.51 MB, which is 0.023 (i.e., 2.3 %).  From the report, it's easy to tell that the majority of database space is taken by DBAReports (approximately 77 %). Data in this column gives DBAs a rough database picture at a glance. The remaining value-related columns are organized in a formula-like structure.

See also: Find size of SQL Server tables and other objects with stored procedure to calculate SQL server table and other object space

See also full instructions available in downloads section: http://license.citruslime.com/cs/files/folders/sample_files/default.aspx

Comments

No Comments