One way is to create a SYNONYM
for Customer.dbo.Table1
in the Supplier
database. You can then query the synonym as though it were in the Supplier
database.
Suppose you have the Customer
database with Table1
and the Supplier
database with Table2
. Suppose both tables are in the dbo
schema. You can then test the following in SQL Server Management Studio (SSMS):
USE Supplier; -- Tell SSMS to switch to the Supplier database
CREATE SYNONYM Table1 FOR Customer.dbo.Table1; -- this creates a synonym permanently in the Supplier database; you only need to execute this once
SELECT * FROM Table1; -- select all from Customer.dbo.Table1, from within the context of database Supplier
This way there is no need for TRIGGER
s and the corresponding overhead (you would need 3 TRIGGER
s to keep the tables in sync).