0
(0)

Below query can be used to check Drive space details in SQL server on Windows platform.

SELECT​​ DISTINCT​​ 

 ​​ ​​ ​​​​ CONVERT(CHAR(80),​​ SERVERPROPERTY('Servername'))​​ AS​​ Server,

 ​​ ​​ ​​​​ volume_mount_point [Drive],​​ 

 ​​ ​​ ​​​​ CONVERT(DECIMAL(20,2),total_bytes/1073741824.0)​​ AS​​ [Total_Size in GB],​​ --1GB = 1073741824 bytes

 ​​ ​​ ​​​​ CONVERT(DECIMAL(20,2),available_bytes/1073741824.0)​​ AS​​ [Available_Size in GB], ​​​​ 

 ​​ ​​ ​​​​ CAST(CAST(available_bytes​​ AS​​ FLOAT)/​​ CAST(total_bytes​​ AS​​ FLOAT)​​ AS​​ DECIMAL(20,2))​​ *​​ 100​​ AS​​ [Free_Space %]​​ 

FROM​​ sys.master_files​​ 

CROSS​​ APPLY​​ sys.dm_os_volume_stats(database_id,​​ file_id)

Sample Output:

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.