SQL Server sink connector

Features

Connector name

sqlserver

Delivery guarantee

At least once

Supported task sizes

S, M, L

Multiplex capability

A single instance of this connector can write to multiple tables in a single schema and database

Supported stream types

Configuration properties

Property Description Required Default

hostname

The host name for your SQL Server database.

Yes

port

The port number to use when connecting to the host.

1433

database-name

The name of the database to connect to.

Yes

schema-name

The name of the schema to which the tables should be written.

Yes

username

The username to use to authenticate to SQL Server.

Yes

password

The password associated with the username.

This must be provided as a secret resource.

Yes

encrypt

Use Transport Layer Security (TLS) encryption.

Must be one of:

  • true

  • false

false

trustServerCertificate

Should the server’s TLS certificate be validated?

Must be one of:

  • true

  • false

Only applicable if encrypt is true

false

Prerequisites

Table names

By default, Decodable uses the stream name as the name of the table it writes to. If a table already exists with that name and the schema of the stream matches the schema of the table, Decodable will write to the existing table. If it doesn’t exist, Decodable will create it.

You can change the name of the table to which Decodable writes either in the web interface, or by using output-resource-name-template when calling decodable connection scan.

The schema of each stream is automatically translated to SQL Server, including:

  • field names

  • data types (See data types for how Decodable types map to SQL Server types)

  • primary keys

Writing data to multiple tables

A single instance of this connector can write to multiple tables in a single schema and database

If you are using the CLI to create or edit a connection with this connector, you must use the declarative approach. You can generate the connection definition for the tables that you want to write to decodable connection scan.

Resource specifier keys

When using the decodable connection scan command of the Decodable CLI to create a connection specification, the following resource specifier keys are available:

Name Description

table-name

The table name

Connector starting state and offsets

A new sink connection will start reading from the Latest point in the source Decodable stream. This means that only data that’s written to the stream when the connection has started will be sent to the external system. You can override this when you start the connection to Earliest if you want to send all the existing data on the source stream to the target system, along with all new data that arrives on the stream.

When you restart a sink connection it will continue to read data from the point it most recently stored in the checkpoint before the connection stopped. You can also opt to discard the connection’s state and restart it afresh from Earliest or Latest as described above.

Learn more about starting state here.

Data types mapping

The following table describes the mapping of Decodable data types to their SQL Server data type counterparts.

Decodable Type SQL Server Type

CHAR(n)

NCHAR(n)

VARCHAR(n)

NVARCHAR(n)

STRING

NVARCHAR(MAX)

BOOLEAN

BIT

BINARY(n)

BINARY(n)

VARBINARY(n)

VARBINARY(n)

DECIMAL(p, s)

DECIMAL(p, s)

TINYINT

SMALLINT

SMALLINT

SMALLINT

INT/INTEGER

INT

BIGINT

BIGINT

FLOAT

FLOAT(24)

DOUBLE [PRECISION]

FLOAT

DATE

DATE

TIME(p)

TIME(p)

TIMESTAMP(p) [WITHOUT TIME ZONE]

(p = 0)

SMALLDATETIME

TIMESTAMP(p) [WITHOUT TIME ZONE]

(0 < p <= 9)

DATETIME2(p)

TIMESTAMP(p) WITH LOCAL TIME ZONE

(0 <= p <= 9)

DATETIMEOFFSET(p)

TIMESTAMP_LTZ(p)

(0 <= p <= 9)

DATETIMEOFFSET(p)