Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Displays info for all files and filegroups in the current Microsoft SQL Server database
SELECT
fg.data_space_id AS FilegroupID,
fg.name AS FileGroupName,
f.file_id AS FileID,
f.name AS LogicalName,
f.physical_name,
fileproperty(f.name,'SpaceUsed')/128 AS Used_MB,
(f.size-fileproperty(f.name,'SpaceUsed'))/128 As Free_MB
FROM
sys.database_files f
LEFT JOIN sys.filegroups fg ON f.data_space_id = fg.data_space_id
ORDER BY
fg.name,
f.name;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.