SQL Server query to show the file size and log usage statistics for all databases.

select instance_name as DatabaseName,
    [Data File(s) Size (KB)],
    [LOG File(s) Size (KB)],
    [Log File(s) Used Size (KB)],
    [Percent Log Used]
from (select *
    from sys.dm_os_performance_counters
    where counter_name in (
        'Data File(s) Size (KB)',
        'Log File(s) Size (KB)',
        'Log File(s) Used Size (KB)',
        'Percent Log Used')
        and instance_name != '_Total'
    ) as Src
    pivot(MAX(cntr_value) for counter_name in (
        [Data File(s) Size (KB)],
        [LOG File(s) Size (KB)],
        [Log File(s) Used Size (KB)],
        [Percent Log Used])
    ) as pvt;