Select
SUM (user_object_reserved_page_count)*8/1024 as user_objects_mb,
SUM (internal_object_reserved_page_count)*8/1024 as internal_objects_mb,
SUM (version_store_reserved_page_count)*8 as version_store_kb,
SUM (unallocated_extent_page_count)*8/1024 as freespace_mb
From sys.dm_db_file_space_usage
where database_id=2