Help Center> Relational Database Service> Troubleshooting> RDS for SQL Server> How Do I Remove and Re-establish a Replication of My RDS for SQL Server Instance?
Updated on 2023-11-03 GMT+08:00

How Do I Remove and Re-establish a Replication of My RDS for SQL Server Instance?

Scenarios

A replication is automatically established for your primary and standby instances in a few minutes after you create or migrate databases to an RDS for SQL Server instance. The time required for a replication depends on the size of your databases.

When necessary, you can remove a replication in either of the following ways:

  • Remove the replication temporarily before you change the database name, configure the snapshot isolation level, or set database properties, to avoid an error similar to the following:
    Figure 1 Error message
  • (Not recommended) If your databases have high performance and throughput requirements, you can remove the replication for a longer period of time.

Fault Analysis

The replication needs to be removed before you perform an ALTER DATABASE operation for your database.

Solution

  1. Remove the replication temporarily.
    1. RDS for SQL Server instances excluding 2017 Enterprise Edition

      Run the following SQL statement to remove the replication of your database:

      alter database [@DBName] set partner off

      [@DBName]: name of the database from which you want to remove the replication

      1. The operation to be performed after the replication is removed must be executed in the same batch as the statement. After the operation is performed, RDS automatically re-establishes a replication for the database.
    2. RDS for SQL Server instances running Microsoft SQL Server 2017 Enterprise Edition

      Run a stored procedure to remove your database from an availability group. For details, see Removing a Custom Database from an Availability Group.

      EXEC rdsadmin.dbo.rds_remove_database_from_ag '@DBName';

      @DBName: name of the database to be removed from an availability group

      Example:

      Remove database testDB_1 from the availability group [AG-RDS-YUN].

      EXEC rdsadmin.dbo.rds_remove_database_from_ag 'testDB_1';
  2. (Not recommended) If the replication is no longer required after being removed, do as follows:
    Remove the replication by following the instructions in 1. If you do not want RDS to automatically re-establish the replication, change the recovery model of the database to Simple in either of the following ways:
    • Log in to the SSMS client, right-click the target database, choose Properties from the shortcut menu, and change the value of Recovery model to Simple.

    • Run the following SQL statement:
      alter database [db1] set recovery simple with no_wait

      In the simple recovery model, no incremental backup is generated. It means that your database cannot be restored to a specified point in time. If you want to restore the replication, set Recovery model to full.

      alter database [db1] set recovery full with no_wait
  3. Check the value of the property Auto Close. If Auto Close of your database is set to True, no replication can be established and no replication alarm is generated.

    To restore the replication, change the value of Auto Close to False.

    alter database [db1] set auto_close off with no_wait