Lance England

Drive Space and File Size via T-SQL

I keep using these scripts so I’m putting them here for convenience.

Drive space for drives on the SQL Server

EXEC MASTER..xp_fixeddrives;

File sizes for all databases

SELECT
    DB_NAME(database_id) AS [Database],
    [Name],
    Physical_Name,
    ROUND((CAST(size AS float) * 8)/1024/1024, 2) AS SizeGB
FROM
    sys.master_files
ORDER BY
    SizeGB DESC
;
27 Aug 2019 Permalink data