http://www.sqlservercentral.com/blogs/basits-sql-server-tips/2013/01/02/sp_spaceused-system-stored-procedure/

Printed 2014/04/16 04:51PM

sp_spaceused system-stored procedure

By Basit Aalishan Masood-Al-Farooq, 2013/01/02

You can use the sp_spaceused system-stored procedure to return space usage information about a database or a table within a database. The syntax for this procedure is:

sp_spaceused [@objectname=['objectname']]
[,[@updateusage=['TRUE|FASLE']]]

You use the objectname parameter to enter the name of a table, indexed view, or Service Broker queue to retrieve space usage information specific to that object. If you set the updateusage to TRUE, DBCC UPDATEUSAGE updates usage information. The default value for this parameter is FALSE.

You can run the command without any parameters to retrieve information about the current database:

sp_spaceused

This returns the following information:

To view information for a table in the current database, you must include the table name. For example, to look at information for the Person.Address table in the AdventureWorks2012 database, you would run:

sp_spaceused 'Person.Address'

This would return:

It is not necessary to include the parameter names (@parametername =) when running this command.



Copyright © 2002-2014 Simple Talk Publishing. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.