set repmode on enables SQL statement replication for the DML operation specified, for the duration of the session. It overrides SQL statement configuration at database and table level.
set repmode on '{UDIS}' | off | never
UDIS – designates the type of DML operation:
U – update
D – delete
I – insert select
S – select into
You can use any combination and order of the letters U, D, I, S as a parameter.
on – enables SQL statement replication for the type of DML operation chosen with the UDIS parameter.
off – clears all previously set session-specific SQL statement replication settings.
never – disables SQL statement replication for the session.
Example 1 To replicate only select into and delete as SQL statements for the duration of the session, use:
set repmode on 'DS'
Example 2 To disable SQL statement replication for the duration of the session, regardless of the database or table-level settings, use:
set repmode never
Example 3 This example illustrates how session-level settings override object-level settings. This example replicates only update statements using SQL statement replication:
set repmode on 'U' go sp_setrepdefmode tabname, on, 'UDI' go
Only a system administrator, database owner, or user with replication_role can execute set repmode.
The default value of set repmode is off.
To override table and database settings, set session-level options either at login using a “login trigger”, or at the beginning of a batch. Session-level parameters are active only for the duration of the session. When you set options from inside a stored procedure or trigger, the option setting is reverted once the stored procedure or trigger has finished executing.
The set options have no effect when a stored procedure
is marked for replication. In such cases, only the call to the stored
procedure is replicated.