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.

Seeing Each Database and Its Disk Size in SQL Server

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.

292 Views

Yavuz Selim Kart

I try to explain what I know in software and database. I am still improving myself by doing research on many programming languages. Apart from these, I am also interested in Graphic Design and Wordpress. I also have knowledge about SEO and Social media management. In short, I am a determined person who likes to work hard.

You may also like...

Don`t copy text!