Forum Discussion
MichaelBurkhardt
Feb 08, 2019Copper Contributor
SQL Server Table Trigger over two Database Server with the same Table Stucture
Hello I have a question
Is it posible to create a Trigger after Update to write the hole updated data to an identical sql server with the same table structur?
To describe this in more detail: Two database servers with identical tables. One Process writes data into Table 'A' and now I want that a trigger (after insert or after update) writes the same Data into table 'A' on the second database server, with the identical table with the same Structure and the same Login. Is this possible?
Greetings from Germany
Michael
Greetings from germany
Michael
- Nirav_GandhiCopper Contributor
Yes. Please follow below step:
- Create Linked server and set "RPC" and "RPC Out" to "True" from "Security Option".
- Linked server user have insert access on table.
- Write four part naming while inserting data in trigger
INSERT INTO [LINKED-SERVER-IP].MyDb.dbo.Customer (CustomerId, CustomerName) SELECT CustomerId, CustomerName FROM MyCustomers WHERE CustomerId = 5
4. Enable Distributed transactions on server.
https://dba.stackexchange.com/questions/218936/insert-trigger-to-a-linked-server-error