Skip to Content

Microsoft SQL Server

There are two methods Etleap uses to extract data from a Microsoft SQL Server source connection: Query-based extractions and Change Data Capture (CDC). With CDC, Etleap will take an initial snapshot of the table using SQL queries and capture incremental changes from the Active Transaction Log and Log Backup Files. With Query-based extractions, all data is extracted with SQL queries.

Source Setup

This setup guide should be followed regardless of whether query-based extractions or CDC will be used to extract the data. To configure the source instance for CDC, complete the steps below, and then follow the guide under Change Data Capture (CDC) Setup .

Step 1. Create a Database User

To extract data from the database, you’ll need to create a new SQL Server user with the minimal permissions to read from the schema you would like Etleap to access. You can complete set up through SQL Server Management Studio (SSMS) or by running SQL queries directly against the source instance.

Create a New User

  1. In the SQL Server Management Studio, open Object Explorer.
  2. Click <instance_name>SecurityLogins.
  3. Right-click Logins and select New Login.
  4. On the General page, in the Login name field, type the name for your new user.
  5. Select SQL Server authentication.
  6. Type a password for the user in the Password and Confirm password field.
  7. Make sure User must change password at next login is unchecked.
  8. For Default database, select the database containing the tables to extract.
A screenshot of the New User screen in SSMS
Creating a new user
  1. On the Securables page click the Search button, select The server <server name>, and click OK.

  2. Select the server in the Securables pane.

  3. Open the Explicit tab in the Permissions for <server name> pane.

  4. Ensure the Connect SQL boxes are checked under the Grant column.

    A screenshot of the Securables page for the new user in SSMS
    Apply the Connect SQL permissions to the new user
  5. On the User Mapping page, select the database that contains the tables to be extracted.

  6. The public role should be automatically enabled.

    A screenshot of the User Mapping page for the new user in SSMS
    Map the new user to the database to replicate
  7. Click OK.

Grant Access to the User

  1. In the SQL Server Management Studio, open Object Explorer.
  2. Open <Instance name>Databases<database name>SecuritySchemas<schema name>.
  3. Right-click on the schema to be accessed by Etleap and click Properties.
  4. On the Permissions page, click the Search button.
  5. Click the Browse button, select the newly created user, and click OK.
A screenshot of SSMS showing the new user being selected when assigning SELECT permissions
Choose the newly created user
  1. Click OK on the search window.
  2. Select the user in the Users or roles pane.
  3. In the Permissions for <user name> pane, open the Explicit tab.
  4. Check the box for Select in the Grant column.
A screenshot of SSSM showing the SELECT permissions for a specific schema being applied to the new user
Grant SELECT privileges on the schema to the new user
  1. Click OK.

  2. You can now use this new user to create a SQL Server connection in Etleap.

Step 2. Whitelist Etleap’s IP Addresses

Etleap’s IP addresses must be whitelisted in SQL Server. There are different addresses to whitelist depending on your deployment model. Review the IP Whitelisting article for more information on which to use.

Follow the steps below to whitelist the necessary IP addresses on a Windows Server:

  1. Open the Windows Control Panel.

  2. Go to Administrative ToolsWindows Defender Firewall with Advanced Security.

  3. On the Inbound Rules page look for a rule named MS SQL Server or Microsoft SQL Server.

    1. If you cannot find a rule for SQL Server, add one by clicking New Rule in the right pane.
    2. Select Program, and click Next.
    3. Specify the path to SQL Server executable on the Windows server and click Next.
    4. Select Allow the connection and choose Next.
    5. Select all three of Domain, Private, and Public and choose Next.
    6. Name the rule MS SQL Server.
  4. Select the rule and click Properties in the right pane.

  5. Open the Scope tab.

  6. Under Remote IP Addresses select These IP addresses.

  7. For each IP address to allow, click Add, enter the address, and click OK.

  8. Click Apply and OK.

    A screenshot of Windows Defender illustrating the steps given above
    Allowing IP addresses in Windows Defender
Note

Prefer using an API? Go here  and select SQL Server under the Body header to create your connection via API.

Change Data Capture (CDC) Setup

This setup guide should be followed before creating a connection in Etleap with the CDC option enabled. The setup steps for both self-managed SQL Server instances and cloud-hosted instances, such as RDS, are detailed below. Ensure the Source Setup steps have been completed first.

Add User Permissions for CDC

The database user requires additional permissions for CDC to work. Follow the steps below to grant the necessary permissions.

  1. In the SQL Server Management Studio, open Object Explorer.
  2. Right-click on <instance_name>SecurityLogins<etleap user>, and select Properties.
  3. On the User Mapping page, select the database to replicate and assign the public and db_owner roles.
A screenshot of SSMS showing the 'my_database' database selected, as well as the 'db_owner' and 'public' roles
The User Mappings configuration for replication

Configure the Database for CDC

For self-managed SQL Server instances, two types of replication are available: MS-Replication, which should be used for tables with primary keys; and MS-CDC, which should be used for tables without primary keys.

undefined

Step 1. Set the Database Recovery Model and Backup

  1. In the SQL Server Management Studio, open Object Explorer.

  2. Right-click on Databases<database to replicate>, and click Properties.

  3. On the Options page, make sure the Recovery model for the publication has been set to Bulk logged or Full:

    A screenshot of the SSMS Database Properties showing the Recovery Model set to Full
    Configure the Recovery Model for the publication
  4. Click OK.

  5. A full backup must be performed before enabling the database for replication.

  6. Right-click on Databases<database to replicate>, and click TasksBack Up.

  7. The Backup type dropdown should be set to Full and DestinationBack up to should be set to Disk.

A screenshot of the configuration for the database backup in SSMS
Take a Full backup of the database before enabling replication
8. Click OK.

Step 2. Configure Distribution and Backup Access

  1. In the SQL Server Management Studio, open Object Explorer.
  2. Right-click on <instance_name>SecurityLogins<etleap user>, and select Properties.
  3. On the User Mapping page, select the msdb and master databases, and check the public role.
A screenshot of SSMS showing the 'master', 'msdb', and 'etleap_test' databases selected, as well as the 'db_owner' and 'public' roles
The User Mappings configuration for replication
  1. Right-click on the Replication folder, and then choose Configure Distribution.
Note

If you do not see the Configure Distribution option, ensure that SQL Server Replication has been installed for the source instance.

  1. On the Distributor step, select Server will act as its own Distributor. Remote distributors are not supported by DMS.
  2. Complete the Configure Distribution wizard.
A screenshot of SSMS showing a successful completion of the Configure Distribution Wizard
A successful completion of the Configure Distribution Wizard
A screenshot of SSMS showing the newly created distribution database
A database for the distribution should now be present under Databases → System Databases
  1. Follow the relevant steps here  to grant the minimal required permissions for the user. Replace DMS_user with the user specified in your Etleap connection.

Step 3. Create a Publication

Follow the steps below to create a publication for each table that you would like to extract data from.

  1. Log in to SSMS using the SYSADMIN user account.
  2. Start a new query with FileNewQuery with Current Connection.
  3. Run the following query to get the DBID for the database you want to replicate in Etleap.
SELECT DB_ID('<database_name>');
  1. Expand the Replication folder in the Object Explorer.
  2. Right-click the Local Publications folder, and choose New Publication.
  3. In the New Publication Wizard, click Next.
  4. Choose the database where you want to create the publication.
  5. Choose Transactional Publication, and then click Next.
A screenshot of the New Publication Wizard in SSMS with Transactional Replication highlighted
  1. Expand Tables, choose the tables you want to replicate, and click Next.
Note

Only tables that have primary keys can be replicated.

A screenshot of the New Publication Wizard in SSMS with the tables to replicate selected
  1. Click Next to skip filter creation as it is not required.

  2. In the Snapshot Agent step, select the Create a snapshot immediately and keep the snapshot available to initialize subscriptions option.

  3. Click Next.

    A screenshot of the New Publication Wizard in SSMS showing the "Create a snapshot immediately" option selected
  4. On the Security step, click the Security Settings button.

  5. Select the Run under the SQL Server Agent service account and By impersonating the process account option.

  6. Click OK.

    A screenshot of the Snapshot Agent Security configuration window in SSMS
  7. Click Next.

  8. Select Create the publication.

  9. Provide a name of the publication in the format AR_PUBLICATION_000XX where XX is the DBID from step 3. For example:

    • If your DBID is less than 10, you need to name the publication AR_PUBLICATION_0000X (4 zeros).
    • If your DBID is greater than or equal to 10, you need to name the publication AR_PUBLICATION_000XX (3 zeros).
  10. Click Finish.

  11. Right-click on ReplicationLocal Publications and click Launch Replication Monitor.

  12. Select the publication you just created and open the Agents tab.

  13. The Snapshot Agent job should have completed successfully and the Log Reader Agent job should be running.

  14. Right-click the Log Reader Agent job and open the Agent Profile.

    A screenshot of the Replication Monitor in SSMS with the Log Reader Agent context menu and the Agent Profile option highlighted
    Open the Agent Profile for the Log Reader Agent
  15. Click New and select the Default agent profile to initialize the new profile from.

  16. Edit the pollinginterval to 86399, which configures unread changed to be purged after a day.

    A screenshot of the New Agent Profile window in SSMS showing the Polling Interval set to 86399
    Configure a higher polling interval than the default
  17. Select the new agent profile and click OK.

    A screenshot of the Agent Profile window in SSMS with the new Agent Profile selected
    Enable the new Agent Profile
Warning

With some versions of SQL Server, if the value of pollinginterval is set to more than 3599 seconds, the value resets to the default five seconds.

When this happens, T-Log entries are purged before the log reader can read them. To determine which SQL Server versions are affected by this known issue, see this Microsoft KB article .

CDC Limitations

Server Limitations

  • Instances hosted on UNIX systems are not supported.
  • The SQL Server version must support TLS 1.2 or higher.

Database and Table Limitations

Data Manipulation Language (DML) and Data Definition Language (DDL) Limitations

  • Changes to computed columns  aren’t replicated.
  • SQL Server partition switching isn’t supported.
  • When using the WRITETEXT and UPDATETEXT utilities, the resulting changes aren’t captured.
  • The following DML pattern isn’t supported:
    SELECT * INTO new_table FROM existing_table
  • Renaming tables and columns using sp_rename  isn’t supported.
  • TRUNCATE TABLE events aren’t captured.
  • Changes to default column values and column nullability are not captured.

Backup Transaction Log Limitations

Backup Transaction Log File Limitations

  • The backup transaction logs must reside in a shared folder with the appropriate permissions and access rights.
  • Active transaction logs are accessed through the Microsoft SQL Server API, and not at file-level.

CDC Error Guides