Seeing Each Database and Its Disk Size in SQL Server
Hello to everyone,
In this article, I will give information about seeing each database and the size of the disk it is on in SQL Server.
In SQL Server, in some cases you may want to see each database and the size of the disk it is on.
You can easily do this using the code below.
SELECT DISTINCT
DB_NAME(dovs.database_id) DBName,
dovs.logical_volume_name AS LogicalName,
dovs.volume_mount_point AS Drive,
CONVERT(INT, dovs.available_bytes / 1048576.0) AS FreeSpaceInMB
FROM sys.master_files mf
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.file_id) dovs
ORDER BY FreeSpaceInMB ASC;
When you run the code, you will see the following result.
As you can see, we have seen each database and the size of the disk it is on in SQL Server.
Good luck to everyone in business and life.