Friday, April 27, 2007

SQL Server - Space Being Used

---------------------------
For Datafiles
---------------------------

use [databaseName]
DBCC showfilestats

An "Extent" in SQL Server is 64 K. So the amount of space in megabytes allocated to Data file can be calculated by using the following formula:

Space Allocated for Data = TotalExtents * 64.0 / 1024.0

And the amount of space in megabytes used by Data can be calculated using the following formula:

Space Used for Data = UsedExtents * 64.0 / 1024.0

---------------------------
For Logfiles
---------------------------

DBCC sqlperf(logspace)

Transaction Log Space Used = Log Size (MB) * Log Space Used (%).

No comments: