Data file space used | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

Data file space used

Hi All, Does anyone know how to get the data file space used from a database? Apart from the taskpad, I can’t find any other way to get the space that is actually used in the space allocated to the data file. I can use DBCC SQLPERF(logspace) to get the space used by the log file, is there something out there that will give the same results for data files? Thanks
An undocumented stored procedure sp_MStablespace which returns the number of rows in a table and the space of the table and index use.
sp_MStablespace [name] [, id] HTH Satya SKJ
This posting is provided “AS IS” with no rights for the sake of knowledge sharing.
If don’t need tables details, us sp_spaceused.
Luis Martin
Moderator All postings are provided “AS IS” with no warranties for accuracy.
To get the space used in a database file run: SELECT CONVERT(float,size) * (8192.0/1024.0) AS size_in_KB FROM dbo.sysfiles WHERE fileid=1 Change the fileid to the file you want to check (select * from dbo.sysfiles)