Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQL Server trigger on replication

I need to create a SQL Server database that will recieve updates by some replication mechanism from another database. I need to write insert, update and delete triggers that will execute when this replilcation occurs.

I have experience with triggers but not with replication.

Should I use Transactional or Merge replication, or does it matter?

Will a trigger designed to run when a simple SQL insert statement is executed also run when replication occurs?

like image 782
Liam Avatar asked Dec 30 '22 05:12

Liam


1 Answers

The CREATE TRIGGER syntax on MSDN:

CREATE TRIGGER
...
[ NOT FOR REPLICATION ] 

This indicates that executing on replication is the default behaviour for triggers, and can be disabled by specifying NOT FOR REPLICATION.

like image 161
Liam Avatar answered Jan 08 '23 13:01

Liam