The sys.dm_db_file_space usage DMV returns information about database file space usage. This DMV was enhanced for the 2012 version to include 3 additional columns. Let’s query this DMV against our AdventureWorks2012 database and view the results.
SELECT * FROM sys.dm_db_file_space_usage
The column returned from this DMV are really self-explanatory, but I will give you a description, paraphrased from books online, below.
The first three columns returned from this DMV represent the Database, File, and Filegroup for the current database context that executed the DMV query. The next column is the total_page_count which represents the total number of pages in the file. The allocated_extent_page_count represents the total number of pages in all extents that have been allocated. The unallocated_extent_page_count represents the number of pages in the unallocated extents within the file. The version_store_reserved_page_count column represents the number of pages that are allocated to the version store. The user_object_reserved_page_count represents the number of pages allocated for user objects. The internal_object_reserved_page_count represents the number of pages allocated for internal objects. Lastly is the mixed_extent_page_count which represents the total number of pages that are part of mixed extents.
This is a great DMV for retrieving usage space information from your database files.
For more information about this DMV, please see the below Books Online link:
Follow me on Twitter @PrimeTimeDBA