SQLTeam.com | Weblogs | Forums

Invalid object name 'sys.dm_os_volume_stats'


#1

I am trying to select 15% of disk space available in a server.

 SELECT DISTINCT
        s.volume_mount_point [Drive],
        CAST(s.available_bytes / 1048576.0 as decimal(20,2)) [AvailableMBs],
       ((CAST(s.total_bytes / 1048576.0 as decimal(20,2)))*15)/100 AS [FifteenpercentAvailableMBs]  

        FROM 
                sys.master_files f
                CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.[file_id]) s

This query works well in Microsoft SQL Server 2008 R2 (SP2)

But it wont work in Microsoft SQL Server 2008 R2 (RTM)

How can I make this query work in 2008 R2 RTM? (I mean is there any alternative query that I can use to get 15% of available space?)


#2

According to the documentation, this DMV was introduced in SQL Server 2008 R2 SP1.

You might be able to use xp_fixeddrives go get the free space on local hard drives.


#3

Why are you running RTM?! There have been thousands of bug and security fixes since then.


#4

Hi Graz - Thank you for the reply. When I use XP_Fixeddrives I am getting
Invalid object name 'xp_fixeddrives' Error.


#5

Hi Tara - We have so many old servers we are still supporting. I am going to install the latest SP3 today.