Can we use 2 database connections to different servers within the same editor using MJOIN or LEFTJO?

Can we use 2 database connections to different servers within the same editor using MJOIN or LEFTJO?

KrishnadornadulaKrishnadornadula Posts: 2Questions: 2Answers: 0
edited June 2020 in Free community support

I have 2 database servers and have them stored as DBCONNECTIONProd and DBCONNECTION.

The DBTYPE is always Sqlserver.

I want to join tables in 2 different servers/databases using MJOIN or LeftJoin

        var dbType = Environment.GetEnvironmentVariable("DBTYPE");
        var dbConnection = Environment.GetEnvironmentVariable("DBCONNECTIONProd");
        var dbConnectiondev = Environment.GetEnvironmentVariable("DBCONNECTION");

        using (var db = new Database(dbType, dbConnection))

Answers

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin

    Are they different actual servers, or just different databases on the same server? If multiple databases on the same server then you just need a single connection, and it must have access permissions to both databases. Then you will be able to do db1.table1, db2.table2 like you would in a regular SQL query.

    If however they are completely different servers, then no, this is not possible at all with our libraries. Indeed, I don't even know if it is possible with SQLServer - I suspect not without linking them in some way, or pulling the data from one to the other.

    Allan

This discussion has been closed.