Skip to content

Instantly share code, notes, and snippets.

@petesql
Created September 27, 2017 15:30
Show Gist options
  • Save petesql/60695b157a76dc06401608a94641e52b to your computer and use it in GitHub Desktop.
Save petesql/60695b157a76dc06401608a94641e52b to your computer and use it in GitHub Desktop.
Volume info for all LUNS that have database files on the current instance
SELECT DISTINCT vs.volume_mount_point, vs.file_system_type,
vs.logical_volume_name, CONVERT(DECIMAL(18,2),vs.total_bytes/1073741824.0) AS [Total Size (GB)],
CONVERT(DECIMAL(18,2), vs.available_bytes/1073741824.0) AS [Available Size (GB)],
CONVERT(DECIMAL(18,2), vs.available_bytes * 1. / vs.total_bytes * 100.) AS [Space Free %]
FROM sys.master_files AS f WITH (NOLOCK)
CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) AS vs
ORDER BY vs.volume_mount_point OPTION (RECOMPILE);
@petesql
Copy link
Author

petesql commented Sep 27, 2017

SQL 2012 and above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment