Set Thresholds and Operations at Database Level

Use the threshold parameter for the sp_setrepdbmode command to set thresholds at the database level.

These examples show how to set the threshold at the database and table levels, and at the same time define operations at the different levels.

Example 1

This example shows how to set a different threshold at the database and table levels for the pubs2 database and table1 table:

  1. Reset the threshold at the database level to the default of 50 rows:

    sp_setrepdbmode pubs2, ‘threshold’, ‘0’
    go
  2. Enable SQL statement replication of update, delete, insert, and select into operations for pubs2:

    sp_setrepdbmode pubs2, ‘udis’, ‘on’
    go
  3. Trigger SQL statement replication for table1 in pubs2 only for the operations you defined in step 2 when these operations affect more than 1,000 rows:

    sp_setrepdefmode table1, ‘threshold’, ‘1000’
    go

Example 2

This example shows how to define the threshold at the database level for pubs2, and at the same time define different operations for tables, such as table1 and table2 located in the pubs2 database:

  1. Set the threshold at the database-level to trigger SQL statement replication when a data manipulation language (DML) statement affects more than 100 rows:

    sp_setrepdbmode pubs2, ‘threshold’, ‘100’
    go
  2. Define a different set of operations for two specific tables, where you want operations replicated using SQL statement replication. Update, delete, and insert operations are for table1 and delete operations are for table2:

    sp_setrepdefmode table1, ‘udi’, ‘on’
    go
    sp_setrepdefmode table2, ‘d’ ‘on’
    go

When a delete operation executes against table2 or any DML on table1 executes, the threshold of 100 rows that you defined at the database-level triggers SQL statement replication when reached.