July 7, 2014 at 10:43 am
Hello experts,
I need a T-SQL or Powershell script/Stored procedure which accepts instance name as parameter and outputs the disk space usage for the drive on which instance data is available - Capacity, free space, used space and pct free. Please help, urgent.
Regards,
Chandu.
July 7, 2014 at 11:16 am
Master_Files returns one row for each database file, and dm_os_volume_stats is a table valued function that returns information about a volume. Remember to get maximum value for each volume (not summarization), or else you will double count.
SELECT volume_mount_point, logical_volume_name, max(total_bytes)total_bytes, max(available_bytes)available_bytes
FROM sys.master_files AS f
CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id)
group by volume_mount_point, logical_volume_name;
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply