It isn’t very clear what you want to do. Do you want to get a list of databases in the instance? If this is what you want you can use this query:
select @@servername, name from master.sys.databases
If you want something else, pleas specify.
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/