In order to programmatically determine Free Hard Disk Space using T-SQL, use the extended stored procedure master.dbo.xp_fixeddrives which returns a list of all hard drives and the free space(in MB) for each of the hard drive.
DECLARE @OSDriveSpace TABLE
INSERT INTO @OSDriveSpace
SELECT * FROM @OSDriveSpace
Note: The T-SQL query shown above does not take into account Volume Mount Points. If you need to include mount points and monitor them, then make sure you check out this article CLR stored procedure to get disk space information which shows how to use a CLR stored procedure to return the capacity and free space of a mount point.
Did you like this post?
|subscribe via rss||subscribe via e-mail|
|print this post||follow me on twitter|