SET NOCOUNT ON;
SELECT
    d.name AS db_name,
    CONVERT(varchar(19), d.create_date, 120) AS created,
    d.state_desc AS state,
    CONVERT(varchar(19), act.last_activity, 120) AS last_index_activity,
    CONVERT(varchar(19), bak.last_backup, 120) AS last_backup
FROM sys.databases d
OUTER APPLY (
    SELECT MAX(v) AS last_activity
    FROM (
        SELECT last_user_seek AS v FROM sys.dm_db_index_usage_stats WHERE database_id = d.database_id
        UNION ALL
        SELECT last_user_scan FROM sys.dm_db_index_usage_stats WHERE database_id = d.database_id
        UNION ALL
        SELECT last_user_lookup FROM sys.dm_db_index_usage_stats WHERE database_id = d.database_id
        UNION ALL
        SELECT last_user_update FROM sys.dm_db_index_usage_stats WHERE database_id = d.database_id
    ) x
) act
OUTER APPLY (
    SELECT MAX(backup_finish_date) AS last_backup
    FROM msdb.dbo.backupset
    WHERE database_name = d.name AND type = 'D'
) bak
ORDER BY d.create_date DESC;
