List Databases In Use - SQL Server

Overview

The following SQL statement gives a list of all databases that are active (online) for a SQL Server instance.

SQL Statement

select 
    name, state_desc
from 
    sys.databases
where 1=1
    and name not in ('master','msdb','tempdb','model')
    and state_desc not in ('OFFLINE','SUSPECT')
order by 
    name