DBCC command for data file size
Is their a DBCC command or some other kind of command that can show how much of data file is actually being used? I looking for something similar to the DBCC SQLPERF (LOGSPACE) command, but for data files
February 27th, 2007 8:33am

Do you want a DBCC command or will any other command also be ok ?

sp_spaceused

HTH, Jens K. Suessmeyer.

---
http://www.sqlserver2005.de
---
Free Windows Admin Tool Kit Click here and download it now
February 27th, 2007 12:21pm

Hi Jens,

the sp_spaceused seems to do the trick, but only for one database. Is there a way to show database size for a number of databases like the DBCC comand that shows all the log files.

February 27th, 2007 2:40pm

You might try this:

-- Individual File Size query
SELECT name AS 'File Name' , physical_name AS 'Physical Name', size/128 AS 'Total Size in MB',
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS 'Available Space In MB', *
FROM sys.database_files;

You could write a script like this to hit all of your databases.

USE DatabaseName;

GO

SELECT name AS 'File Name' , physical_name AS 'Physical Name', size/128 AS 'Total Size in MB',
size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS int)/128.0 AS 'Available Space In MB', *
FROM sys.database_files;

GO

Free Windows Admin Tool Kit Click here and download it now
February 27th, 2007 10:50pm

DBCC showfilestats
July 6th, 2009 3:17pm

sp_databases
Free Windows Admin Tool Kit Click here and download it now
August 18th, 2015 11:52am