Calculate Diskspace Used by a Table or Database

Ever wondered how much storage space a particular table in your SQL Server database takes up? It's actually *really* easy to find out! Simply do

EXEC sp_spaceused 'tablename'

where tablename is the table you're interested in, and you'll get back something that looks like this:

names rows reserved data index_size unused
dir_pages
4308 13088 KB 12928 KB 88 KB 72 KB

If you omit the 'tablename' parameter, then you'll get back two resultsets with information about the entire database:

database_name database_size unallocated space
devfusion
11248.69 MB 18.52 MB

reserved data index_size unused
87856 KB 81232 KB 5152 KB 1472 KB

 

You might also like...

Comments

James Crowley James first started this website when learning Visual Basic back in 1999 whilst studying his GCSEs. The site grew steadily over the years while being run as a hobby - to a regular monthly audience ...

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Anyone who considers arithmetic methods of producing random digits is, of course, in a state of sin.” - John von Neumann