Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DB Size Monitor Script 1

Status
Not open for further replies.

muftak

MIS
May 8, 2003
12
0
0
CA
Does anyone know of an sp, or have a script that will return ONLY the amount of Used Data Space?

Any help would be appreciated.
 
try this hope this helps

exec sp_MSforeachdb 'Use [?] exec sp_spaceused'
 
Thanks nowayout .... but I'm looking for a way to return just a single number, the amount of Used Data Space in a single DB. For example, in mysql, I do something like:

echo "SIZE: $SIZE"
 
Thanks tlbroadbent ... but again, I'm just looking for the USED DATA SPACE.

Example: DB is 1GB, 524MB is used 500MB is free. I'm looking for a way to return just the 524MB number.

I haven't been able to find away to just get that number returned, which is why I've posted here.
 
--return the database space used in MB
Select DBSpaceUsed = cast(8.0*sum(Reserved)/1024. As Decimal(15,2))
from sysindexes
where indid in (0, 1, 255)

You may need to run exec sp_spaceused @updateusage='true' to update statistics so the correct size is returned.

If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Thank You very much ... that works perfectly.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top