Print database_size from sp_spaceused Using SQL Server 2008, I have found that the database size can be obtained using

exec sp_spaceused


This procedure returns two tables:

database_name | database_size | unallocated space


reserved | data | index_size | unused


I would like to create a query where the only output of the SQL call is the value returned for database_size.  I do not want any extraneous output (no table headers, column names, etc).

Is there a simple way to do this?
Another way to accomplish this without the creating database objects is to use the below query taken from the sp_spaceused stored procedure itself:

declare @dbsize bigint
declare @logsize bigint

select @dbsize = sum(convert(bigint,case when status &amp; 64 = 0 then size else 0 end))
, @logsize = sum(convert(bigint,case when status &amp; 64 &lt;&gt; 0 then size else 0 end))
from dbo.sysfiles

select ltrim(str((convert (dec (15,2),@dbsize) + convert (dec (15,2),@logsize)) 
* 8192 / 1048576,15,2) + ' MB') as Database_Size