Skip to content

Commit 014f857

Browse files
DOCSP-33730 SQL Server Migration Prereqs (#80)
* DOCSP-33730 SQL Server Migration Prereqs --------- Co-authored-by: jocelyn-mendez1 <[email protected]>
1 parent 91e5522 commit 014f857

File tree

2 files changed

+145
-1
lines changed

2 files changed

+145
-1
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
To enable CDC at the database level
2+
use the ``sys.sp_cdc_enable_db`` stored procedure.
3+
4+
The code blocks below are a sample of the code
5+
automatically-generated by Relational Migrator.
6+
You can run the code manually by replacing the
7+
database name for ``MyDB``:
8+
9+
.. code-block:: sql
10+
:copyable: true
11+
12+
USE MyDB
13+
GO
14+
EXEC sys.sp_cdc_enable_db
15+
GO
16+
17+
For SQL Server instances hosted on AWS RDS:
18+
19+
.. code-block:: sql
20+
:copyable: true
21+
22+
USE MyDB
23+
GO
24+
EXEC msdb.dbo.rds_cdc_enable_db 'MyDB';
25+
GO

source/prerequisites/sql-server.txt

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,123 @@ SQL Server Migration Prerequisites
1010
:depth: 1
1111
:class: singlecol
1212

13-
SQL Server.
13+
To run sync jobs from a SQL Server source database,
14+
the database may require some configuration changes. Before you start a
15+
sync job, Relational Migrator checks if the
16+
database is configured correctly. If Relational Migrator determines the
17+
database needs configuration changes, it automatically generates a
18+
SQL script with the required changes. It is recommended to have a
19+
Database Administrator (DBA) review the commands in this script and
20+
perform their execution on the database server. This topic
21+
provides more details on the required configuration steps. SQL Server
22+
configuration depends on the type of sync job:
23+
24+
- Snapshot sync jobs migrate all the data and then stops.
25+
- Continuous sync job run a snapshot and then enter a CDC stage to
26+
continuously replicate data changes.
27+
28+
About this Task
29+
---------------
30+
31+
- This page covers the details of the SQL scripts automatically
32+
generated by Relational Migrator.
33+
34+
- Relational Migrator automatically detects configuration settings when
35+
connecting to your database and generates the appropriate SQL
36+
statements to enable CDC if required.
37+
38+
- Relational Migrator does not create any indexes on SQL Server to
39+
facilitate sync jobs. The create index creation permission is not
40+
required.
41+
42+
Steps
43+
-----
44+
45+
The easiest way to set up your database is to run the automatically
46+
generated script that Relational Migrator prompts you to download when
47+
you :ref:`create a sync job <rm-create-jobs>`. To understand the
48+
permissions or run the SQL manually, read the procedures below.
49+
50+
Configure your SQL Server instance based on the sync job type.
51+
Refer to the tab below for details on snapshot and continuous sync
52+
job configurations.
53+
54+
.. tabs::
55+
56+
.. tab:: Snapshot Jobs
57+
:tabid: enable-snapshot-jobs
58+
59+
For snapshot jobs against SQL Server, you must enable
60+
CDC at the database level.
61+
62+
.. procedure::
63+
:style: normal
64+
65+
.. step:: Configure CDC at the Database Level
66+
67+
Enabling CDC at the database-level CDC generates a small
68+
number of system tables in the database, leaving user tables
69+
unchanged, and does not add any performance overhead. Enabling
70+
CDC alone does not result in changes being captured.
71+
72+
.. include:: /includes/fact-enable-cdc-database.rst
73+
74+
.. tab:: Continuous Jobs
75+
:tabid: enable-continuous-jobs
76+
77+
For continuous jobs against SQL Server, you must enable
78+
CDC at both the database level and at the table level for
79+
each table.
80+
81+
.. procedure::
82+
:style: normal
83+
84+
.. step:: Configure CDC at the database level
85+
86+
.. include:: /includes/fact-enable-cdc-database.rst
87+
88+
.. step:: Enable the SQL Server agent and check database permissions
89+
90+
To enable the CDC option at the table level:
91+
92+
a. You must have the server level ``sysadmin`` role.
93+
#. You must have the database level ``db_owner`` role.
94+
#. The `SQL Server agent <https://learn.microsoft.com/en-us/sql/ssms/agent/sql-server-agent?view=sql-server-ver16>`__
95+
must be running.
96+
#. The service account used to connect to SQL Server
97+
must have Select permission against all required tables.
98+
99+
.. step:: Configure CDC at the table level
100+
101+
To enable CDC at the table level
102+
use the ``sys.sp_cdc_enable_table`` stored procedure.
103+
104+
You can check the SQL Server CDC settings by examining the ``is_tracked_by_cdc``
105+
column in the `sys.tables catalog view <https://learn.microsoft.com/en-us/sql/relational-databases/system-catalog-views/sys-tables-transact-sql?view=sql-server-ver16>`__.
106+
A value of ``1`` for ``is_tracked_by_cdc`` indicates the table
107+
is enabled for change data capture.
108+
109+
The code block below is a sample of the
110+
automatically generated code.You can run the code manually
111+
to enable table CDC:
112+
113+
.. code-block:: sql
114+
:copyable: true
115+
116+
USE MyDB
117+
GO
118+
EXEC sys.sp_cdc_enable_table
119+
@source_schema = N'dbo',
120+
@source_name = N'MyTable',
121+
@role_name = N'MyRole',
122+
@filegroup_name = N'MyDB_CT',
123+
@supports_net_changes = 1
124+
GO
125+
126+
Learn More
127+
----------
128+
129+
Relational Migrator relies on the open-source Debezium connector to
130+
capture row-level changes. For more details, see
131+
`Debezium SQL Server <https://debezium.io/documentation/reference/stable/connectors/sqlserver.html#_enabling_cdc_on_a_sql_server_table>`__.
132+

0 commit comments

Comments
 (0)