HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Is it possible to JOIN to a Primary database from a Replication instance?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
primaryjoinreplicationdatabaseinstancepossiblefrom

Problem

I have a database on a Replication server that doesn't exist on the Primary server.

There are stored procedures on the Replication server's DB that join to tables in other databases on the Replication server. These should be joining to tables on the Primary server.

Is this possible? If so, how?

This is an example of what it's currently doing:

UPDATE  c
SET     CRP_Id      = be.EventId
FROM    #TempEvent be
JOIN        CRP.dbo.Payments c -- *should* be joining to CRP on Primary, not Replication
    ON  c.CRP_TransactionId     = be.SourceTransactionId
WHERE   be.EventTypeId  in  (
                                @MyEventTypeId
                            );

Solution

You should use linked server and use four part naming linkedservername.dbname.schema.object

Also refer my answer on efficient way of pulling data when using linked server

Context

StackExchange Database Administrators Q#117799, answer score: 2

Revisions (0)

No revisions yet.