Friday, August 31, 2012

SQL Server: Displaying the sizes of your database's tables

For maintenance purpose, I needed to create a dashboard that reports database tables’ size to monitor growth of them. The first command that should be known is the sp_spaceused stored procedure. This command returns the following information:
·         Name (table name)
·         Rows (number of rows existing)
·         Reserved (Total amount of reserved space)
·         Data (Total amount of space used by data)
·         Index_size (Total amount of space used by indexes)
·         Unused (Total amount of space reserved but not yet used)
EXEC sp_spaceused 'dbo.Countries'