Sql Server Disk Control

HKN MZ
Towards Dev
Published in
1 min readDec 24, 2023

--

This SQL query is designed to generate a report focused on the physical locations of files in a SQL Server database and the disk usage statistics associated with those locations. Here’s the code.s

select distinct
vs.volume_Mount_point,
vs .logical_volume_name,
file_system_type,
drive_size_GB = convert( decimal( 19, 2), vs.total_bytes /1024. /1024. /1024. ) ,
drive_free_space_GB = convert( decimal( 19, 2), vs.available_bytes /1024. /1024. /1024. ),
drive_percent_free = CONVERT( DECIMAL( 5, 2), vs .available_bytes * 100.0 / vs.total_bytes ),
stuff((select ', ', DB_NAME(database_id) from…

--

--

I am writing about Sql Server, Elasticsearch and Python. İ am an Database Administrator on SQL Server and Elasticsearch more than 5+ years.