Get List of Companies database using MSSQL Query

SOLVED

Hi,

I want to create a Business Intelligence Report by using Report Manager & Connector.

In this report, I want to get rows from table APPYM of all Companies database. 

But first, I need to know which database is actually a company database for Sage 300 in my server.

I was planning to do this:

- write a stored procedure to select rows from x numbers of company databases.

- call the stored procedure in connector, this connector will be used by my report in report manager.

However, I did not see any way to collect the database name.

I have check SAMSYS & PORTAL database. 

In PORTAL, we have table Tenant that have column Company that  list down the company db name. But  for my case, not all company is going to have portal, so I will miss out some company that don't have Portal.

So, How to get the list of Companies database programmatically using MSSQL?