SQL script to get drive free space details

How to get SQL associated mount point drive details using query

Using below SQL query we can get drive details (only we can get drives which are associated to SQL server )

copy the below query to the new query window and hit F5

SELECT DISTINCT dovs.logical_volume_name AS LogicalName,
dovs.volume_mount_point AS Drive,
CAST(total_bytes / 1048576 as decimal(12,2)) [TotalMB],
CAST((CAST(available_bytes / 1048576 as decimal(12,2)) ) - (CAST(total_bytes / 1048576 as decimal(12,2))) as decimal(12,2)) [Used Space MB],
CAST(available_bytes / 1048576 as decimal(12,2)) [FreeSpaceMB],
ISNULL(ROUND(available_bytes / CAST(NULLIF(total_bytes, 0) AS FLOAT) * 100, 2), 0) as percent_available
FROM sys.master_files mf
CROSS APPLY sys.dm_os_volume_stats(mf.database_id, mf.FILE_ID) dovs
ORDER BY FreeSpaceMB ASC
GO


we can get mounted volume details using above query.

Labels: ,

Post a Comment

Post a Comment

Emoticon
:) :)) ;(( :-) =)) ;( ;-( :d :-d @-) :p :o :>) (o) [-( :-? (p) :-s (m) 8-) :-t :-b b-( :-# =p~ $-) (b) (f) x-) (k) (h) (c) cheer
Click to see the code!
To insert emoticon you must added at least one space before the code.

Author Name

Contact Form

Name

Email *

Message *

Powered by Blogger.