select substring (S.name,1,20) segment_name,
sum (U.size) /512 total_size_mb,
sum(curunreservedpgs(db_id(), U.lstart, 0)) /512 free_space_mb,
convert (int,100*sum(curunreservedpgs(db_id(),U.lstart, 0))/ sum (U.size)) free_space_pc
            from syssegments S,
            master..sysusages U,
            master..sysdevices D
            where dbid = db_id()
            and vstart between low and high
            and power (2,S.segment) & U.segmap > 0
            group by S.name
go
