When using large databases it might be interesting to keep an eye out on what of your tables that actually consumes all that disk.

There´s a lot of resources on this out there but I thought I´d repeat it anyways since its such a neat little thing:

EXEC sys.sp_spaceused 'thetable'

It will show you a neat table gridview of your database table size like this:

And if you like you can use the this to retrieve it for all your tables in one grid:

 -- Declare a temp in-memory-table

 DECLARE @sizeTable as TABLE (name varchar(50), numrows int, reserved varchar(50), data varchar(50), index_size varchar(50), unused varchar(50))

 -- Select out the results of sp_spaceused for each table

 INSERT INTO @sizeTable (name, numrows, reserved, data, index_size, unused)

 EXEC sys.sp_MSforeachtable 'EXEC sp_spaceused ''?'' '

 -- Select from the temp-table

 SELECT * FROM @sizeTable
Why not join the newsletter?

Why not join the newsletter?

If you're not a fan of facebook or twitter, sign up to the newsletter and I'll send you a quick update every so often with what's going on and new posts coming out.

You have Successfully Subscribed!