Microsoft SQL Server Batch

Microsoft SQL Server Batch

Certified

Bulk insert rows into Microsoft SQL Server using prepared statements

Reads ION-formatted data from Kestra internal storage and performs high-performance batch inserts using JDBC batch operations. Data is processed in chunks (default 1,000 rows) to optimize memory and performance. Supports auto-commit for databases without transaction support.

yaml
type: io.kestra.plugin.jdbc.sqlserver.Batch

Fetch rows from a table and bulk insert to another one.

yaml
id: sqlserver_batch_query
namespace: company.team

tasks:
  - id: query
    type: io.kestra.plugin.jdbc.sqlserver.Query
    url: jdbc:sqlserver://dev:41433;trustServerCertificate=true
    username: "{{ secret('SQL_USERNAME') }}"
    password: "{{ secret('SQL_PASSWORD') }}"
    sql: |
      SELECT TOP (1500) *
      FROM xref;
    fetchType: STORE

  - id: update
    type: io.kestra.plugin.jdbc.sqlserver.Batch
    from: "{{ outputs.query.uri }}"
    url: jdbc:sqlserver://prod:41433;trustServerCertificate=true
    username: "{{ secret('SQL_USERNAME') }}"
    password: "{{ secret('SQL_PASSWORD') }}"
    sql: |
      insert into xref values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? )

Fetch rows from a table and bulk insert to another one, without using sql query.

yaml
  id: sqlserver_batch_query
  namespace: company.team

  tasks:
    - id: query
      type: io.kestra.plugin.jdbc.sqlserver.Query
      url: jdbc:sqlserver://dev:41433;trustServerCertificate=true
      username: sql_server_user
      password: "{{ secret('SQL_SERVER_PASSWD') }}"
      sql: |
        SELECT TOP (1500) *
        FROM xref;
      fetchType: STORE

    - id: update
      type: io.kestra.plugin.jdbc.sqlserver.Batch
      from: "{{ outputs.query.uri }}"
      url: jdbc:sqlserver://prod:41433;trustServerCertificate=true
      username: "{{ secret('SQL_USERNAME') }}"
      password: "{{ secret('SQL_PASSWORD') }}"
      table: xref
Installation

Our standard Docker images already include this plugin. If you use a -slim image or another setup, install it with the following command:

kestractl plugins get io.kestra.plugin:plugin-jdbc-sqlserver --compatible-for $KESTRA_VERSION

For kestractl, use your Kestra version with --compatible-for, or specify an exact plugin version.

For Kestra CLI, replace LATEST with a specific version or version range to pin the plugin version.

Properties

Input file from internal storage

URI of the source file (kestra://) containing rows to insert

The JDBC URL to connect to the database

Assets this task consumes as inputs or produces as outputs, for lineage tracking and the asset graph (Enterprise Edition). A flow declaring this property on a task is rejected in the open-source edition.

Definitions
assetFailureBehaviorstring
Possible Values
IGNOREFAILWARN

Asset failure behavior

Behavior applied to the task state when a declared asset fails to render, emit, or be persisted (e.g. a lock conflict): FAIL escalates it to FAILED, WARN (default) warns it if it would otherwise succeed, IGNORE leaves the state untouched.

enableAutobooleanstring

Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.

inputsarray

The assets consumed as inputs.

id*string
Min length1
typestring
outputs

The assets produced as outputs.

id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*object
descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
id*string
Min length1
Max length150
type*string
Min length1

Custom asset type

descriptionstring
displayNamestring
metadataobject
Default{}
namespacestring
Min length1
Max length150
Default1000

Batch size per executeBatch call

Number of rows sent per JDBC batch before commit; default 1,000

SubTypestring

Columns bound to placeholders

Ordered column names matching ? placeholders; if omitted, placeholder count must match all columns in the input row

DefaultFALSE
Possible Values
TRUEFALSESTRICTOPTIONAL

Whether to encrypt the connection

Controls JDBC encryption between the client and SQL Server. Defaults to FALSE to preserve backward compatibility with mssql-jdbc 12.x behavior. Set to TRUE or STRICT for encrypted connections. Note: if your SQL Server has "Force Encryption" enabled server-side, the server will require TLS regardless of this setting. In that case, ensure your server supports TLS 1.2+ and its certificate is properly configured, otherwise you may get "unexpected_message" errors during the TLS handshake.

The hostname expected in the server certificate

Specifies the host name to be used when validating the SQL Server TLS/SSL certificate. If not set, the driver uses the server name from the connection URL.

DefaultAUTO
Possible Values
AUTOSTREAMLOCAL

Input handling strategy

Controls how input is read during processing and retries. AUTO buffers small files locally (<= localBufferMaxBytes) and streams large files. STREAM always streams from internal storage. LOCAL always buffers input to a local temporary file before processing.

Default104857600

Maximum number of bytes buffered locally

Used by AUTO and LOCAL input handling. In AUTO, files larger than this threshold are streamed. In LOCAL, files larger than this threshold fail fast.

Default3

Maximum number of retries for transient failures

Retries are attempted only for transient failures such as temporary I/O and recoverable SQL errors.

Defaultfalse

Expose the executed SQL statement in the outputs

When true, the INSERT statement is exposed in the statement output, truncated to 64 KiB. Disabled by default so that SQL text never leaks into outputs unless requested

The database user's password

Defaulttrue

Resume from the last successfully committed chunk on retry

DefaultPT1S

Delay between retry attempts

Uses ISO-8601 duration format, for example PT1S.

DefaultINPUT
Possible Values
NONEINPUTALL

Controls which failures are retried

INPUT retries input handling failures, ALL retries all retryable failures.

Parameterized INSERT statement to execute

Prepared INSERT with ? placeholders for each bound column. Example: INSERT INTO <table_name> VALUES (?, ?, ?) for three columns; use column list if inserting a subset

Table used to auto-discover columns

Retrieves column names from the given table when columns is empty. If sql is also omitted, an INSERT statement is generated automatically using the discovered columns

The time zone id to use for date/time manipulation. Default value is the worker's default time zone id

Defaultfalse

Whether to trust the server certificate without validation

When set to true, the driver does not validate the SQL Server TLS/SSL certificate. Useful for development or self-signed certificates.

The path to the trust store file

Specifies the path (including file name) to the certificate trust store file. Used when encrypt is TRUE or STRICT to validate the server certificate.

The trust store password

The password used to access the trust store file.

The database user

Batch execution duration in milliseconds

Includes input handling and retries

Total rows read

Number of rows affected by the batch

Sum of the update counts reported by the JDBC driver for every executed batch

Executed SQL statement

Only populated when outputStatement is true; truncated to 64 KiB

Tables written by the statement

Detected from the SQL text, so this is a best effort. Limited to 50 entries, see tablesTruncated

Definitions
accessstring
Possible Values
READWRITECREATEDROP

How the statement uses the table

One of READ, WRITE, CREATE or DROP.

confidencestring
Possible Values
MEDIUMLOW

How reliable the detection is

MEDIUM when detected from the SQL text, LOW for temporary tables and ambiguous names.

databasestring

Database name

Null when the statement does not qualify the table with a database.

kindstring
Possible Values
TABLEFILEURL

Kind of source

Only set on DuckDB: TABLE, FILE or URL (files read through read_parquet, read_csv, ATTACH and quoted paths).

namestring

Table name

For DuckDB file reads, the file path or URL.

schemastring

Schema name

Null when the statement does not qualify the table with a schema.

Whether the tables list was cut at 50 entries

Rows inserted or updated

Kept for compatibility, prefer rowsAffected

Number of SQL warnings raised by the batch

Count of the SQLWarning chain reported by the driver across all executed batches

The duration of the batch execution, including input handling and retries.

Unitqueries

The number of batch queries executed.

Unitrecords

The number of records processed.

Unitrows

The number of rows affected, as reported by the JDBC driver.

Unitrecords

The number of records updated.