THE SQL Server Blog Spot on the Web

Welcome to - The SQL Server blog spot on the web Sign in | |
in Search

Tibor Karaszi

Util procedure to show database size

One of the first things I want to do when I look at a new SQL Server is to get an idea of space usage details for each database, including total space usage. For this I have been using my own sp_db_space_usage for a while now, so I decided to add it to my website ( Check it out here.
Published Tuesday, December 29, 2009 2:17 PM by TiborKaraszi
Filed under:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS



Uri Dimant said:

Hi Tibor

I would add that those numbers are in MB/KB/GB... and /or perhaps the percent usage % or data and log files, what do you think?  

December 29, 2009 7:46 AM

TiborKaraszi said:

Hi Uri,

I had that originally (MB), but decided to remove it to keep the result as slim as possible... :-)

December 30, 2009 2:50 AM

csm said:

Hi Tibor,

there's an error on the definition for #dbcc_sqlperf_logspace table. The datatype for database_name column must be sysname (or something similar), not varchar(32).

Anyway, thanks for the script

January 13, 2010 7:33 AM

TiborKaraszi said:

Hi csm,

That type (varchar(32) is actually deliberate. It was there for tools which doesn't adjust width according to data size. I.e., so we don't have to scroll that much side-ways when reading the result. I think it had to do with 2000 tool (the proc is supposed to be runnable on 2000), but exact details escapes me at the moment.

Sysname would be the type to use if you don't want to truncate long db name - that is correct. :-)

January 13, 2010 11:15 AM

csm said:

But with 32 characters only, the procedure raise an exception (i.e., the AdminContent database in a Sharepoint implementation)

January 18, 2010 3:53 AM

TiborKaraszi said:

You are absolutely right. I guess I only tested it with db names shorter than 32, in order for the tool to not have a too wide column. I now tested it with a long db name and I get the same truncation messaged. I fixed that datatype, changed it to sysname. The "right" way to cut down the length would have been to use CAST or CONVERT on the final select instead of having a smaller type in the input table...

January 19, 2010 11:29 AM

Leave a Comment


This Blog


Privacy Statement