SELECT name FROM master.dbo.sysdatabases
To exclude non-user DBs:
... WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb');
or
SELECT * FROM sys.databases d WHERE d.database_id > 4
SELECT name FROM master.dbo.sysdatabases
To exclude non-user DBs:
... WHERE name NOT IN ('master', 'tempdb', 'model', 'msdb');
or
SELECT * FROM sys.databases d WHERE d.database_id > 4