Login or Sign Up to become a member!
LessThanDot Site Logo

LessThanDot

Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.

Navigation

Google Ads

Getting the amount of free space for each drive with T-SQL

From Wiki

Jump to: navigation, search

Sometimes you want to quickly see how much free space each drive has on your SQL Server machine. You can of course use RDP/Terminal Services to logon to the machine and take a look. But there is an easier way, you can do it with T-SQL.

SQL Server ships with an undocumented stored procedure that will give you the free space for each drive on your machine. The name of this stored procedure is xp_fixeddrives. This stored procedures doesn't require any parameters and it will list all drives and how much free space in megabytes each drive has.

Run the following code on your machine

  1. exec master..xp_fixeddrives


Here is the output from that query for me

drive MB free
----- -----------
C     2128
D     28921
L     85459
M     5896
T     86068
U     145048
V     248584


As you can see I still have plenty of space left on the V drive.


Contributed by: --SQLDenis 17:09, 16 April 2010 (GMT)

Part of SQL Server Admin Hacks

722 Rating: 2.8/5 (48 votes cast)