• Sgar... (5/13/2015)


    I am using this query. It gives me Total bytes and Free bytes in MB. I want to include free % in same query, But I am not able to do so. It is giving me either 0 or different values. Can anyone help here

    I am trying the commented part for free %.

    SELECT @@SERVERNAME as 'Servername',

    (((SUM(total_bytes))/1024)/1024)/1024 as 'Total_space(In MB)' ,

    (((SUM(available_bytes))/1024)/1024)/1024 as 'Available_space (in MB)',

    /* ( ( (SUM(total_bytes)) / (SUM(available_bytes)) ) *100) as 'Free SPace in %' */

    FROM master.sys.master_files AS f

    CROSS APPLY sys.dm_os_volume_stats(f.database_id, f.file_id)

    where f.file_id=1 and f.database_id > 4 and Volume_mount_point like '%S%'

    This query has an incorrect syntax, guess you left some bits out.

    😎

    Can you elaborate on what you are referring to as "free %"? Is it disk space, allocated file space, table space or up in space?