The system stored procedures sp_who and sp_who2 will list the processes currently logged onto the server and information about them, among other things which database they are connected to.
They get their information from the sysprocesses and sysdatabases system tables which you can also query.
Jeff Mason
Custom Apps, Inc.
www.custom-apps.com