Updated on 2026-10-26 GMT+08:00

Configuring the DRS Synchronization Task

  1. Enter the source and destination database information, and test the connection. After the connection test is successful, click Next.

    Table 1 Source database settings

    Parameter

    Description

    IP Address or Domain Name

    IP address in the overview of the Azure SQL instance.

    Port

    Default port.

    Database Username

    High-privilege user provided by the customer for migration.

    Database Password

    The password for the source database username.

    Test Connection

    Ensure that the connection test is successful.

    Table 2 Destination database settings

    Parameter

    Description

    DB Instance Name

    The RDS DB instance you selected when creating the synchronization task. This parameter cannot be changed.

    Database Username

    Administrator account for creating the RDS for SQL Server DB instance.

    Database Password

    The password for the destination database username.

    Test Connection

    Ensure that the connection test is successful.

  2. Click Agree and Continue. The page for editing the synchronization task is displayed.
  3. On the Set Synchronization Task page, do not select Table structure for Synchronization Object Type. Select the tables to be synchronized for Synchronization Object.

  4. On the Check Task page, if CDC is not enabled for the source database and tables, an error message is displayed, indicating that CDC is not enabled. For items that fail the check except CDC, rectify the fault as prompted or contact oncall personnel.

  5. Use SSMS to connect to Azure SQL and enable CDC for the database and each table in sequence.

    1. Enable database-level CDC.
      EXEC sys.sp_cdc_enable_db;

      If the current Azure SQL Database does not support CDC, CDC fails to be enabled at the database level, and an exception occurs. In this case, run the subsequent SQL statements to upgrade the Azure SQL Database and enable the database-level CDC.

      Query the service level of the source database and record the result for later restoration:

      • The following editions do not support CDC: Basic, Standard S0, Standard S1, and Standard S2.
      • The billing varies depending on the edition of Azure SQL Database.
    2. Query the original service edition of the database.
      SELECT 
          database_name = DB_NAME(),
          edition,
          service_objective
      FROM sys.database_service_objectives;

      Then run the following SQL statements in sequence to enable the service edition of the source database:

      (The 5.b.i, 5.b.ii, and 5.b.iii SQL statements are optional. If the database-level CDC fails to be enabled, run the 5.b.i, 5.b.ii, and 5.b.iii SQL statements, refresh the database, and enable the database-level CDC again.)

      1. Upgrade the database to the Premium edition of Azure SQL Database that supports CDC.
        ALTER DATABASE [smsa_mig]
        MODIFY (EDITION = 'Premium', SERVICE_OBJECTIVE = 'P1');
      2. Disable database-level DDL triggers:
        DISABLE TRIGGER ALL ON DATABASE
      3. Disable database-level CDC.
        EXECsys.sp_cdc_disable_db;
      4. Enable database-level CDC.
        EXEC sys.sp_cdc_enable_db;

        After CDC is enabled for the source database, check the service edition of the source database again. The service edition has been upgraded to Premium.

    3. Enable CDC for all tables in batches. Execute the SQL script for enabling CDC for tables in batches (the script needs to be modified based on the schema and executed for each schema).
      BEGIN TRY
          DECLARE @source_name VARCHAR(400);
          DECLARE @sql VARCHAR(1000);
          DECLARE @dbname VARCHAR(100);
          DECLARE @schemaname VARCHAR(100), @enable BIT;
      
          SET @dbname = 'smsa_migration'; -- Ensure that the database name is correct.
          SET @schemaname = 'SalesLT'; -- Change the schema to the one to be processed (for example, SalesLT or dbo).
          SET @enable = 1;                 -- 1: Enable CDC. 0: Disable CDC.
      
          DECLARE the_cursor CURSOR FAST_FORWARD FOR
          SELECT table_name
          FROM INFORMATION_SCHEMA.TABLES 
          WHERE TABLE_CATALOG = @dbname 
            AND TABLE_SCHEMA = @schemaname 
            AND TABLE_NAME != 'systranschemas'
            AND TABLE_TYPE = 'BASE TABLE'; -- Key correction: Select only base tables and exclude views.
      
          OPEN the_cursor;
          FETCH NEXT FROM the_cursor INTO @source_name;
      
          WHILE @@FETCH_STATUS = 0
          BEGIN
              IF @enable = 1
              BEGIN
                  SET @sql = 
                      'USE ' + @dbname + '; ' +
                      'EXEC sys.sp_cdc_enable_table ' +
                      '@source_schema = N''' + @schemaname + ''', ' +  -- Schema name
                      '@source_name = N''' + @source_name + ''', ' +    -- Table name
                      '@role_name = NULL;';  -- Set the role name as required. NULL indicates that the access is not restricted.
              END
              ELSE
              BEGIN
                  SET @sql = 
                      'USE ' + @dbname + '; ' +
                      'EXEC sys.sp_cdc_disable_table ' +
                      '@source_schema = N''' + @schemaname + ''', ' +  -- Schema name
                      '@source_name = N''' + @source_name + ''', ' +    -- Table name
                      '@capture_instance = ''all'';'; -- Disable all instances.
              END
      
              PRINT @sql; -- Debug and output the generated SQL.
              EXEC(@sql);
              FETCH NEXT FROM the_cursor INTO @source_name;
          END
      
          CLOSE the_cursor;
          DEALLOCATE the_cursor;
          SELECT 'Successful';
      END TRY
      BEGIN CATCH
          IF CURSOR_STATUS('global', 'the_cursor') >= 0
          BEGIN
              CLOSE the_cursor;
              DEALLOCATE the_cursor;
          END
      
          SELECT
              ERROR_NUMBER() AS ErrorNumber,
              ERROR_MESSAGE() AS ErrorMessage;
      END CATCH

    4. Run the following SQL statement to check whether CDC is enabled for all source tables:
      select name, is_tracked_by_cdc from sys.tables where is_tracked_by_cdc = '1';

  6. Click Check Again to start the check again until the check success rate reaches 100%.

  7. Retain the default settings and click Submit.
  8. In the displayed dialog box, select I have read the precautions before startup and click Submit. You can view the task status in the Status column of the task list.