Skip to main content

Microsoft SQL Server

Extract loads source data into Microsoft SQL Server tables using SQL authentication and encrypted connections. The destination supports Append, Replace, Upsert, History, SoftDelete, Replica, and partition overwrite, plus Debug Queries for inspecting the loaded data.

Prerequisites​

  • An existing SQL Server database reachable from the Extract worker. Configure routing and firewall access to the server's TCP port, usually 1433.
  • A dedicated SQL login and database user with permission to create and manage destination tables (and, if applicable, create schemas).
  • TLS is required. Provide a server certificate whose hostname matches SQL Server Host and whose certificate authority is trusted. For a private certificate authority, supply its PEM root certificate in TLS CA Certificate.

This connector uses SQL Server username/password authentication. Windows/Kerberos authentication, Microsoft Entra authentication, and SSH tunneling are not supported by its current setup fields.

Authentication​

Extract connects to Microsoft SQL Server using SQL Server authentication (username and password) over TLS-encrypted connections.

Provide the following credentials:

  • Host: SQL Server hostname or IP address
  • Port: SQL Server port (typically 1433)
  • Database: target database name
  • Username / Password: SQL Server login credentials with access to the target database

Connections require TLS encryption. If your SQL Server uses a certificate signed by a private or internal CA, configure the connector to trust that CA by supplying the CA certificate (PEM). This allows certificate verification to remain enabled (recommended) while supporting on-prem/self-managed deployments.

Setup guide​

Ask your database administrator to create a dedicated SQL login and map it to the target database. For a SQL Server instance, the following example uses an existing database named extract:

USE [master];
GO
CREATE LOGIN [extract_user] WITH PASSWORD = '<replace-with-a-strong-password>';
GO
USE [extract];
GO
CREATE USER [extract_user] FOR LOGIN [extract_user];
GO

Replace the example names and password before running the statements. See Microsoft's SQL login setup and database user documentation for your deployment's authentication model.

2. Create a destination schema and grant permissions​

Using a dedicated schema keeps Extract's tables separate from other application tables. Run these statements in the target database as an administrator:

CREATE SCHEMA [extract] AUTHORIZATION [dbo];
GO
GRANT CONNECT TO [extract_user];
GRANT CREATE TABLE TO [extract_user];
GRANT SELECT, INSERT, UPDATE, DELETE, ALTER
ON SCHEMA::[extract] TO [extract_user];
GO

For this configuration, enable Use an existing schema when setting up the destination and set the connection's Schema to extract.

If you want Extract to create schemas automatically, leave Use an existing schema disabled and grant the database user CREATE SCHEMA as well. The user still needs permission to manage tables in any existing schema it uses. See Microsoft's database permissions documentation.

3. Configure the destination in Extract​

Create a Microsoft SQL Server destination and enter:

SettingWhat to enter
SQL Server HostServer hostname matching its TLS certificate.
PortTCP port; defaults to 1433.
UsernameSQL login name.
PasswordSQL login password.
DatabaseExisting target database name.
Use an existing schemaEnable to prevent automatic schema creation; defaults to disabled.
TLS CA CertificateOptional PEM root certificate for a private certificate authority, including its BEGIN/END markers.

Save the destination and check its login status. A successful login confirms access to the database; the first connection run also checks the permissions needed to write tables.

TLS certificate and hostname validation remain enabled when a custom CA is provided. Do not put a private key in the certificate field.

4. Create a connection and select streams​

Choose a source and the SQL Server destination, then configure:

SettingScopeBehavior
SchemaConnectionTarget schema; defaults to dbo.
Table Name PrefixConnectionOptional prefix applied to every destination table name.
Schema Migration PolicyConnectionControls automatic stream activation, added fields, safe type widening, and field deprecation. By default, new fields are added.
Table Name OverrideStreamOptional replacement for the stream's table name. The connection's prefix still applies.

Select the fields and a supported load mode for each stream. Start a run and use Debug Queries to verify the results.

Load modes​

The available load modes depend on the source stream's extraction mode:

Extraction modeSupported load modes
Full refreshAppend, Replace, SoftDelete
Incremental changesAppend, Upsert, History, Replica
PartitionAppend, Replace
  • Append adds incoming rows and preserves existing rows. Replaying the same input adds it again.
  • Replace with full refresh replaces all rows in the table. A successful empty refresh clears the table.
  • Upsert inserts new primary keys and updates existing keys, including composite keys. If a batch contains the same key more than once, the last incoming row wins.
  • History preserves versions using _singular_active, _singular_start, and _singular_end. It requires a primary key and a source timestamp with microsecond precision. Replayed key/timestamp pairs are skipped; duplicate pairs within one batch and unknown out-of-order versions fail.
  • SoftDelete updates or inserts incoming rows and marks missing rows with _singular_deleted. Returning rows are restored. An empty full refresh marks all existing rows deleted. Without a primary key, this mode falls back to full Replace.
  • Replica applies compatible CDC events using _extract_deleted, _extract_cdc_lsn, and _extract_commit_timestamp. Deleted rows remain as tombstones. Older or replayed sequence numbers do not overwrite newer rows; this mode requires the source's CDC fields, not ordinary incremental rows alone.

Partition overwrite uses Replace with partition extraction. It replaces only partitions present in the incoming data, including a null partition key. Other partitions remain unchanged; empty input replaces no partitions.

Extract stages each stream before applying its target changes in a transaction. Source or loading failures roll back uncommitted target changes. If a connection is lost during commit and the outcome is unknown, inspect the destination before retrying an Append run to avoid duplicates.

Data types and existing tables​

Text is stored as Unicode NVARCHAR; integers use BIGINT, booleans use BIT, dates use DATE, and timestamps use DATETIMEOFFSET(7). Numbers use FLOAT, or DECIMAL(38,18) when specified by the source schema. JSON, objects, and arrays are serialized into NVARCHAR(MAX), preserving JSON strings and booleans. Missing and null values become SQL NULL.

Values that would exceed a column's supported length, integer range, decimal precision, or timestamp precision fail rather than being silently truncated or rounded. Exponent notation is supported for decimals when the value fits exactly within 20 integer and 18 fractional digits.

Primary keys and collation​

Upsert, History, Replica, and keyed SoftDelete require selected, non-null primary-key fields. Existing target rows with null key components must be corrected before loading.

New keyed tables use unique nonclustered indexes; History enforces uniqueness only for active versions. Incoming composite keys must fit SQL Server's 1,700-byte nonclustered key limit. Text keys without a bounded source length use NVARCHAR(850). The combined actual key size is checked on every run, so later growth can fail even if earlier values fit. Pre-created tables with narrower columns or clustered keys can have stricter limits.

Text columns created, added, or widened by Extract use Latin1_General_100_BIN2 collation. This keeps keys such as ABC and abc distinct. Existing text primary-key columns used by keyed modes, and text partition-key columns used by partition Replace, must use that same collation.

If an existing table has an incompatible key collation, the run fails before changing its rows. Have your administrator migrate the key columns and their dependent indexes, or recreate the destination table and fully reload it from the source. Changing collation cannot recover rows already combined by earlier case-insensitive loads. SQL Server's trailing-space comparison rules still apply: keys differing only in trailing spaces are not distinguished.

Schema changes​

Extract applies enabled schema-migration policies for added, renamed, deprecated, and changed fields. Automatic type changes allow safe widening; potentially lossy conversions require an explicit migration. Existing NOT NULL constraints are preserved.

Identifiers are limited to 128 UTF-16 code units, and selected field names cannot differ only by case. On a case-sensitive database, pre-created column names must match the source catalog's spelling. Switching load modes may require migrating managed columns such as History or SoftDelete fields before the next run.

Debug Queries​

Use the existing Debug Queries screen to select fields, apply filters and date windows, group rows, calculate aggregations, preview results, download results, and retrieve row counts from the destination. This feature uses the existing query controls; the destination does not add an arbitrary-SQL editor.

Configuration​

Provide the following configuration values when creating the Microsoft SQL Server destination.

SettingDescription
HostSQL Server hostname or IP address.
PortSQL Server port (typically 1433).
UsernameSQL Server login username (SQL authentication).
PasswordSQL Server login password.
DatabaseTarget database name.
SchemaTarget schema to write tables into (for example, dbo).
Table prefixOptional prefix applied to all destination tables created/managed by Extract.
Disable automatic schema creationWhen enabled, Extract will not attempt to create the destination schema automatically. Ensure the schema already exists and the user has the required permissions.
TLS CA certificate (optional)PEM-encoded CA certificate to trust when connecting over TLS (useful for private/on-prem certificates). If provided, Extract uses it to validate the server certificate.

The destination user must be able to create and modify tables in the target schema (and create temporary staging tables during loads). At minimum, grant permissions to create/alter tables and read/write data in the target schema.

Notes​

  • Extract connects using TLS encryption.
  • For reliable key matching, Extract uses a binary collation for text key columns (Latin1_General_100_BIN2). If you are loading into existing tables with text keys, ensure those key columns (and dependent indexes) use this collation, or recreate the table and perform a full reload.

Data Contract Information​

This destination supports data contracts.

When you enable a data contract for a model, Extract uses the contract to:

  • Create the destination table (if it doesn’t already exist).
  • Validate and evolve the table schema on subsequent runs:
    • New fields in the contract may be added as new columns.
    • Type changes are applied only when they are compatible with the existing table.
    • If the destination table contains columns not present in the contract, they are left as-is.

Keys and constraints​

If your contract defines key fields, Extract uses them to enforce deterministic upserts/merges. For SQL Server, key columns are created using a binary collation to ensure case- and accent-sensitive matching:

  • Latin1_General_100_BIN2

If your existing destination table uses a different collation on key columns, you may need to migrate those columns (and any dependent indexes/constraints) or recreate the table and perform a full reload.

Notes for existing tables​

When writing into an existing table, Extract expects the table to be compatible with the contract (column names and types). If SQL Server rejects a write due to conversion, truncation, nullability, or duplicate key violations, update the contract and/or destination schema to match the actual data being loaded.

Notes​

  • Extract connects to SQL Server using TLS encryption (EncryptionLevel::Required). If your SQL Server uses a private or self-signed certificate, configure the connector to trust your CA (rather than disabling certificate verification).

  • For case-sensitive and accent-sensitive key matching, Extract uses the Latin1_General_100_BIN2 collation for NVARCHAR key columns it creates. If you load into an existing table whose key columns use a different collation, you may see collation-related errors or incorrect key matching. In that case, migrate the key columns (and any dependent indexes) to Latin1_General_100_BIN2, or recreate the destination table and perform a full reload.

  • SQL Server error messages can include row values (for example, in conversion, truncation, or duplicate-key errors). To avoid leaking data into logs, Extract may redact the server-provided message and instead surface a generic action to take based on the SQL Server error code.

Troubleshooting​

Error or symptomWhat to check
UnknownIssuer or another certificate validation errorConfigure a trusted server certificate or supply the correct PEM root CA. The host must still match the certificate.
Login succeeds but a run fails with a permissions errorCheck database/schema permissions, including permission to create/alter tables and to modify existing target tables.
Incompatible destination key collationText key columns must use Latin1_General_100_BIN2 collation. Migrate the key columns and their dependent indexes to Latin1_General_100_BIN2, or recreate and fully reload the table.
Existing destination rows contain NULL in one or more key columnsClean up or migrate those rows so all key components are non-NULL, then retry.
Composite key exceeds the index limitReview the combined key size and source key design. Do not truncate identifiers to make them fit.
A decimal or timestamp cannot be represented exactlyCheck source precision and the destination type; correct or explicitly transform the source value before retrying.
Duplicate key / constraint violationsVerify the configured key fields are unique and non-NULL in the source data, and that the destination table’s primary key matches the connector key configuration.
Deadlocks / lock timeouts / blocked writesCheck for concurrent writes to the same target tables and reduce contention (for example, schedule runs to avoid overlapping writers).
Commit outcome may be unknownVerify the destination state before replaying the run, especially for Append.

For a development database, follow Microsoft's SQL Server container quickstart. Microsoft supports those container images on Intel/AMD x86-64 Linux hosts. The database must be reachable from the Extract worker: localhost refers to the worker's own host, not your laptop when using a hosted worker.