Sources

SQL Server

Check which SQL Server versions SQL Flow supports and choose between DirectLog, Reconstruction, Polling and Native CDC.

SQL Flow captures changes from SQL Server 2016 SP2 and later in four capture modes. They differ in where they read changes from, what they need on the database host, and what the login must be allowed to do.

Supported versions

VersionSupported
SQL Server 2016 SP2 (13.0.5026) and laterYes, in every capture mode
SQL Server 2016 RTM and SP1, and every older releaseNo. The source test and every start refuse them by name.
Reconstruction on SQL Server 2016 SP2 and 2017Yes, with a signed helper procedure that a sysadmin installs once. See Reconstruction.
Azure SQL Managed InstanceYes, added as a SQL Server source, with Native CDC or Polling. DirectLog and Reconstruction need a log broker on the database host, which Managed Instance doesn't allow.
Azure SQL Database and HyperscaleUse the Azure SQL source.

An unsupported version is refused with this message:

SQL Server 2016 SP2 (13.0.5026) or later (the source reports version <version>, which is SQL Server 2016 RTM or SP1; apply Service Pack 2). Azure SQL Database, Managed Instance and Hyperscale are supported.

DirectLog and Reconstruction also need the SQL Server host to run Windows Server 2016 or later, or Linux, because the log broker runs there. DirectLog needs Standard, Enterprise or Developer edition, because Express and Web can't mark tables for capture.

Capture modes

ModeWhat it readsWhat you install on the database host
DirectLogThe transaction log file (.ldf), through a log broker. The tables are marked for capture with SQL Server's CDC procedures.A log broker
ReconstructionThe same .ldf through the same broker, with no CDC and no marking. Some updates carry the row's current value rather than every intermediate version.A log broker
PollingThe log records, returned by sys.fn_dblog over the ordinary connection.Nothing
Native CDCSQL Server's own change tables under the cdc schema, filled by the CDC capture job.Nothing

The wizard selects DirectLog by default when you choose a SQL Server source. You change the mode with the Capture mode buttons on the Source step.

Choosing a capture mode

  1. Can you install a log broker on the SQL Server host? Managed services such as Amazon RDS don't allow it.
    • No: go to question 4.
    • Yes: go to question 2.
  2. Is the database encrypted with TDE? DirectLog and Reconstruction read the raw log, which TDE encrypts on disk.
    • Yes: go to question 4.
    • No: go to question 3.
  3. May the database have CDC enabled and the selected tables marked for capture, by a login that is db_owner?
    • Yes: use DirectLog. It reads every change from the log, with lag in milliseconds and no query work on the server to find changes.
    • No: use Reconstruction. It needs no CDC and no database role, and the target converges to the source rather than replaying every intermediate version of a row. On SQL Server 2016 SP2 and 2017, a sysadmin installs a signed helper procedure once.
  4. Is CDC already enabled, or may it be enabled, with the capture job running?
    • Yes: use Native CDC.
    • No: use Polling. Its login needs sysadmin or db_owner, and every read costs the server query work.
DirectLogReconstructionPollingNative CDC
Reads from.ldf via log broker.ldf via log brokersys.fn_dblogcdc change tables
Log broker on the hostRequiredRequiredNot usedNot used
CDC on the databaseEnabled; tables markedNot usedNot usedEnabled on database and tables
Login roledb_ownerNone, specific grantssysadmin or db_ownerNone, SELECT on the tables and the cdc schema
LagMillisecondsReads the log as it is written, like DirectLogSecondsThe capture job's scan interval
Source loadLog bytes, plus off-row values over SQLLog bytes, plus keyed reads of current rowssys.fn_dblog query work for every readThe capture job, plus reads of the change tables
Holds the source logYes, until the target commits; released on pauseNoNoNo; the CDC capture job does
Every intermediate update versionYesNo: converges to the current rowYesYes
TDE databaseRefusedRefusedSupportedSupported
sql_variant into SQL Server and Azure SQL targetsYes, outside the keyYes, outside the keyRefusedRefused
Tables with a column setRefusedRefusedSupportedRefused by SQL Server's CDC
CLR user-defined typesCaptured as bytesRefusedCaptured as bytesRefused
Recovery modelFULL with a log backup chainFULL with a log backup chainFULL with a log backup chainAny
Minimum version2016 SP22016 SP2 (a signed helper on 2016 SP2 and 2017)2016 SP22016 SP2

See Choosing a capture mode for the comparison across every source engine.

Encrypted data

DirectLogReconstructionPollingNative CDC
Transparent Data Encryption (TDE)RefusedRefusedSupportedSupported
Always Encrypted columnsRefused by default; ciphertext copy as an opt-inRefusedRefusedRefused
Encrypted connectionAlwaysAlwaysAlwaysAlways
  • TDE. DirectLog and Reconstruction read the raw .ldf, which TDE encrypts on disk, so they refuse a TDE database. Polling and Native CDC read the log through the engine, which decrypts it.
  • Always Encrypted. Every mode refuses a selected table with an Always Encrypted column. DirectLog alone can copy the ciphertext unchanged to a SQL Server or Azure SQL target that uses the same column encryption keys. See DirectLog: Encrypted data.
  • Connections. The agent always encrypts its connection to SQL Server. With Encryption at Require (default), it also validates the server certificate. For an on-premises server with a self-signed certificate, set Encryption to Prefer: the connection stays encrypted, but the certificate isn't checked. A host name under .database.windows.net, such as a Managed Instance, is always validated.

See Encrypted data support for every engine.

See also

Previous
LogMiner

If this was useful,
our newsletter will be too.

Get monthly insights on data engineering, AI, and building critical infrastructure - direct from the Spectral Core team and CEO Damir Bulic.