List all Databases and Their Associated Files

30 09 2014

Sometimes we need a clear picture for a project or perhaps we have just taken over a new server to administer. We need to know certain things like what the heck is going on with all of these databases and why is the disk full?

select d.name, d.recovery_model_desc , d.is_encrypted, mf.name, mf.physical_name, ((mf.size * 8) / 1024) as 'File Size (MB)', mf.type_desc as 'type' FROM sys.databases d
Inner join sys.master_files mf on d.database_id = mf.database_id