I wrote the below query to calculate the free data space avaialble for each database present in the server. Can any of you please go through this and correct if I am wrong.
-------------------------------------------
select
"DB"= convert(char(10),db_name(dbid)),
"DB_Free_Space_Percentage" = convert(varchar(6),round(sum(unreservedpgs) * 100 / sum(size),0))
from sysusages u
where segmap = 3 and dbid not in (3,31513,31514)
group by dbid
order by 2
----------------------------------------
Thank you