Batch Processing

There are some requirements when you apply SQL statement replication to any DML statement that is executed in a batch.

In the example below, while executing the batch statement with delete and insert, only the first statement uses SQL statement replication. table2 uses traditional replication because table2 is not configured to use SQL statement replication:

create table table1 (c int, d char(5)) 
go
create table table2 (c int, d char(5))
go
insert table1 values (1, 'ABCDE') 
go 100
sp_setreptable table1, true 
go 
sp_setreptable table2, true 
go
sp_setrepdefmode table1, 'UDI', 'on' 
go
delete table1 where c=1 
insert table2 select * from table1 
go
Related reference
Exceptions to Using SQL Statement Replication