try out this function
select name from sysdatabases
where name not in ('master','model','msdb','tempdb','pubs','Northwind')
and DATABASEPROPERTYEX(name,'status')='ONLINE'
i got it from Hall of Fame (Rudy Komacsar Senior Database Administrator)
for more information read the following thread
http://www.sqlservercentral.com/Forums/Topic371321-5-1.aspx