SQL Server as Source - DSS 6 | Data Source Solutions Documentation
Documentation: SQL Server as Source - DSS 6 | Data Source Solutions Documentation
SQL Server as Source
Capture
Data Source Solutions DSS allows you to Capture changes from SQL Server database. This section describes the configuration requirements for capturing changes from SQL Server location. For the list of supported SQL Server versions from which DSS can capture changes, see Capture changes from location in Capabilities.
DSS uses the Microsoft ODBC Driver for SQL Server to capture changes from an SQL Server location.
Table Types
DSS supports capture from the following table types in SQL Server:
- clustered (row/page compressed and uncompressed)
- heap (row/page compressed and uncompressed)
DSS does not support capture from memory optimized tables and trigger-based capture from temporal tables.
Sparse Columns
DSS supports capture from SQL Server sparse columns starting from version 6.2.5/7. While capture from sparse columns may appear to work in earlier DSS versions, it can result in data integrity issues.
To ensure data integrity when replicating tables with sparse columns, you must perform an index rebuild if any columns have been dropped or altered since the last index rebuild.
DSS will prompt for an index rebuild if it detects that sparse column IDs cannot be reliably mapped. This happens when either of the following has occurred since the last index rebuild:
- Columns were dropped.
- Columns were altered in a way that causes SQL Server to internally drop and recreate them (e.g., changing column nullability).
If you are upgrading the DSS Hub and DSS Agent from a version earlier than 6.2.5/7, you must perform Activate Replication with the Table Enrollment option selected, or run dssactivate with the -oe option.
Capture Methods
DSS allows the following methods for capturing (Capture) changes from SQL Server:
-
Direct Transaction Log Access
Capture changes directly from SQL Server's logging files. This capture method is supported on:- The primary database server with a connection to the active database.
- A secondary node of an AlwaysOn cluster connected to the local read-only database.
-
Archive Only
Capture changes directly from SQL Server's transaction log backup files (similar to the Direct Transaction Log Access method). This capture method is supported on any server with access to the log backups. -
SQL Access
Capture changes over an SQL connection. This capture method is supported on the primary active database or on a read-only secondary database of an AlwaysOn cluster. -
Database Triggers
<b>Since</b> v6.1.0/3
Capture changes from tables using database triggers.The trigger-based capture method (Capture_Method=DB_TRIGGER) has been deprecated since 6.2.0/0.
Grants for Log-Based Capture
This section lists the grants/permissions required for capturing changes from SQL Server database. Based on your requirement, either of the permissions listed in this section can be used.
For simplicity, we have categorized the required grants into the following three permission models:
- SysAdmin: The easiest to configure and offers broad permissions and authority over the entire SQL Server instance. While easy to set up, it carries potential security risks.
- DbOwner: Provides extensive permissions but is restricted to a specific database. It requires more setup effort than the SysAdmin model.
- Minimal: Requires the least permissions and does not need sysadmin or db_owner rights. However, it is the most complex to configure.
- Until version 6.1.0/12, only the SysAdmin model is supported for the Direct Transaction Log Access capture method. Since version 6.1.0/13, all three permission models are supported for the Direct Transaction Log Access capture method.
- All three permission models are supported for the Archive Only and SQL Access capture methods.
- The DbOwner and Minimal models are only available for SQL Server 2012 and above. For the older versions of SQL Server, the SysAdmin model must be used.
SysAdmin
In this permission model, the DSS database user must be granted sysadmin role.
DbOwner
In this permission model, the DSS database user must be granted the db_owner role. However, a user with sysadmin privileges is required for certain configurations detailed in this section, such as executing specific SQL statements, creating procedures, or granting special permissions to the DSS database user.
Configure the DbOwner permission model
DSS must already be installed before performing the following steps.
-
Create a special 'wrapper' SQL procedure:
This step is needed once when DSS is installed for an SQL Server instance. But if Always On AG is installed, then this step is needed on each Always On AG node.
A user with **sysadmin** privilege must create special 'wrapper' SQL procedures called **sp_dss_dblog** (replaced with **sp_dss_dblog2** in `v6.1.5/5` and later), **sp_dss_dbtable**, and **sp_dss_loginfo**, to enable DSS to call the SQL Server's read-only function **fn_dump_dblog**. This must be done inside the SQL Server database's special database **msdb**, not the actual capture database. The SQL query to create these procedures is available in the file **dsscapsysadmin.sql** in the **DSS_HOME\\dbms\\sqlserver** directory. The DSS database user must then be allowed to execute this procedure. For this, the DSS database user must be added to the special **msdb** database and the following grants must be provided: <div class="callout callout-important">Replace sp_dss_dblog with sp_dss_dblog2 for v6.1.5/5 and later.
```shell
USE msdb;
CREATE USER <em>username</em> FOR LOGIN <em>username</em>;
GRANT EXECUTE ON sp_dss_dblog TO <em>username</em>;
GRANT EXECUTE ON sp_dss_dbtable TO <em>username</em>;
GRANT EXECUTE ON sp_dss_loginfo TO <em>username</em>;
```
-
Grant special read-only privilege:
This step is needed once when DSS is installed for an SQL Server instance. But if Always On AG is installed, then this step is needed on each Always On AG node.
A **sysadmin** user must grant the DSS user login a special read-only privilege in the **master** database. ```shell USE master; GRANT VIEW SERVER STATE TO <em>username</em>; ```In SQL Server 2022, the
VIEW SERVER STATEpermission was split into two permissions:VIEW SERVER PERFORMANCE STATEandVIEW SERVER SECURITY STATE. When capturing from SQL Server 2022, the user only needsVIEW SERVER PERFORMANCE STATE.- Perform special SQL statements:
When Activate Replication is performed, it may need to perform special SQL statements that would require sysadmin or db_owner privilege. One example is that it may need to create an Article on a replicated table to track its changes. In that case, Activate Replication will write the necessary SQL statements into a script file in the DSS_CONFIG\hubs\hub_name\channels\channel_name\locs\location_name\initsql directory on the capture machine. An error message will be displayed, which will list the name of the script file and the necessary permission level. The first time when Activate Replication displays this message, a user with sysadmin privilege must perform these SQL statements on the capture database. Subsequently, these SQL statements can be performed by the DSS database User with db_owner privilege.
Minimal
In this permission model, the DSS database user is not granted, nor does it require, sysadmin or db_owner roles at runtime. However, a user with sysadmin or db_owner privileges is required for certain configurations detailed in this section, such as executing the required SQL statements, creating procedures, and granting the necessary permissions to the DSS database user.
Configure the Minimal permission model
DSS must already be installed before performing the following steps.
-
Create a special 'wrapper' SQL procedure:
This step is needed once when DSS is installed for an SQL Server instance. But if Always On AG is installed, then this step is needed on each Always On AG node.
A user with **sysadmin** privilege must create special 'wrapper' SQL procedures called **sp_dss_dblog** (replaced with **sp_dss_dblog2** in `v6.1.5/5` and later), **sp_dss_dbtable**, and **sp_dss_loginfo** to enable DSS to call the SQL Server's read-only function **fn_dump_dblog**. This must be done inside the SQL Server database's special database **msdb**, not the actual capture database. The SQL query to create these procedures is available in the file **dsscapsysadmin.sql** in the **DSS_HOME\\dbms\\sqlserver** directory. The DSS database user must then be allowed to execute this procedure. For this, the DSS database user must be added to the special **msdb** database and the following grants must be provided: <div class="callout callout-important">Replace sp_dss_dblog with sp_dss_dblog2 for v6.1.5/5 and later.
- Perform special SQL statements: