If you want to know the list of all databases on sql server, you can use one of the following query or stored procedure.
SELECT * FROM sys.databases
SELECT * FROM sys.sysdatabases
EXEC sp_msForEachDB 'PRINT ''?'''
some of these may not work in certain version, it depend on your database server version. Just use the one which work with your server.
Just a normal software developer who love to write code. Developing professional software since 1999. After working in the software industry for many years, I've started my own website to share knowledges and experiences.