how to get other database name which is part of same SQL server

Hello Experts,

I don’t want to hard-code external database name in the code.

In the following code, I was able to get the SQL server value but I don’t know how to get external database name which is part of same SQL server.

static void testODBC(Args _args)
{
    SysServerSessions   serverSessions;
    SysSQLSystemInfo   systemInfo =  SysSQLSystemInfo::construct();
    xSession xSession;

    xSession = new xSession();
    // Prints the name of server for the current session.
    info(xSession.AOSName());
    info(systemInfo.getLoginServer());
    info(systemInfo.getloginDatabase());
}

Any idea how I can get external database name which is part of same SQL server via X++ code?

Kindly advice

Thanks,

Shankar Iyer

You could use a direct SQL query to run EXEC sp_databases or something like that.