
Microsoft SQL Server Queries
CertifiedExecute multiple SQL statements against Microsoft SQL Server
Microsoft SQL Server Queries
Execute multiple SQL statements against Microsoft SQL Server
Runs multiple SQL statements separated by semicolons, either sequentially or within a transaction. Supports parameterized queries and all fetch modes. Set transaction to false to disable transactional behavior (default is true). Default fetchSize is 10,000 rows for STORE mode.
type: io.kestra.plugin.jdbc.sqlserver.QueriesExamples
Execute a query and fetch multiple results.
id: sqlserver_query
namespace: company.team
tasks:
- id: select
type: io.kestra.plugin.jdbc.sqlserver.Queries
url: jdbc:sqlserver://localhost:41433;trustServerCertificate=true
username: "{{ secret('SQL_USERNAME') }}"
password: "{{ secret('SQL_PASSWORD') }}"
sql: select * from employee; select * from laptop;
fetchType: FETCH
Properties
sql *string
SQL statement(s) to execute
Runs one or more SQL statements rendered with flow variables. Query tasks accept a single statement; Queries tasks can execute multiple statements separated by semicolons
url *string
The JDBC URL to connect to the database
afterSQL string
SQL to execute after main query in same transaction
Optional SQL executed in the same transaction after the main statement. Useful for marking rows as processed to avoid duplicates; only a single statement is allowed. Commit covers both sql and afterSQL
assets
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.
io.kestra.core.models.assets.AssetsDeclaration
IGNOREFAILWARNAsset 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.
Whether to auto-register assets referenced dynamically at runtime that are not statically declared in inputs or outputs.
The assets consumed as inputs.
io.kestra.core.models.assets.AssetIdentifier
1The assets produced as outputs.
io.kestra.plugin.ee.assets.Dataset
1150{}1150io.kestra.plugin.ee.assets.File
1150{}1150io.kestra.plugin.ee.assets.Table
1150{}1150io.kestra.plugin.ee.assets.VM
1150{}1150io.kestra.core.models.assets.External
1150{}1150io.kestra.core.models.assets.Custom
11501Custom asset type
{}1150encrypt string
FALSETRUEFALSESTRICTOPTIONALWhether 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.
fetchSize integerstring
10000Number of rows to fetch per database round trip
Controls JDBC fetch size for STORE mode. Default: 10,000 rows; use Integer.MIN_VALUE for MySQL streaming. Ignored for FETCH and FETCH_ONE
fetchType string
NONESTOREFETCHFETCH_ONENONEResult fetching mode
FETCH returns all rows, FETCH_ONE returns the first row only, STORE streams rows to internal storage (ION), NONE returns no data. Default: NONE
hostNameInCertificate string
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.
outputFiles array
Output file names to capture after SQL execution
Creates named temporary files in the task working directory before the SQL runs, making their absolute paths available as {{ outputFiles.name }} Pebble variables in the SQL template. Only supported by embedded, in-process drivers (DuckDB, SQLite) where the database engine writes to the same filesystem as the Kestra worker. Remote database drivers (Postgres, MySQL, etc.) do not support this — they execute SQL on a separate server that cannot write to the Kestra worker filesystem.
parameters object
Named parameter bindings for SQL query
Map of parameter names to values. Use : name placeholders rendered then bound as prepared-statement parameters; supports nulls and typed values
password string
The database user's password
timeZoneId string
The time zone id to use for date/time manipulation. Default value is the worker's default time zone id
transaction booleanstring
trueTransaction
If one query failed, rollback transactions.
trustServerCertificate booleanstring
falseWhether 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.
trustStore string
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.
trustStorePassword string
The trust store password
The password used to access the trust store file.
username string
The database user
Outputs
affectedRows array
The number of affected rows for each query that doesn't return a result set
One entry per INSERT, UPDATE, DELETE or DDL statement, in execution order, as reported by the JDBC driver (DDL statements usually report 0). Queries returning a result set are not included here; their results are in outputs.
outputs array
The list of per-query outputs
io.kestra.plugin.jdbc.AbstractJdbcBaseQuery-Output
First row of fetched data
Only populated when fetchType is FETCH_ONE
List of all fetched rows
Only populated when fetchType is FETCH
Number of rows fetched
Only populated when fetchType is FETCH or STORE
uriURI of stored results in internal storage
Only populated when fetchType is STORE; file is stored in internal storage using ION format
Metrics
fetch.size counter
rowsThe number of fetched rows.