SQL Server - Query
Execute SQL queries and stored procedures on Microsoft SQL Server databases.
Runs one SQL statement on SQL Server or Azure SQL with named @ parameters and returns the rows of the first record set under result.
Connect your SQL Server instance (on-premise or Azure SQL) and run parameterized queries with @paramName binding for SQL injection prevention. Supports connection pooling and automatic cleanup.
Operations:
- SELECT: Fetch rows from tables with filters, joins, and aggregations.
- INSERT: Add new records to tables.
- UPDATE: Modify existing records matching a condition.
- DELETE: Remove records from tables.
- Stored Procedures: Execute stored procedures with named input parameters.
- DDL: Execute CREATE, ALTER, DROP statements for schema management.
How it works
- Resolves the expressions of the node config. Empty
connection_id,sqlandparametersfall back to the field of the same name in the incoming item. - Resolves the credential on the server: a
connection-stringcredential is passed to the driver as is; abasic-auth/objectcredential usesusername(oruser),password,serverorhost,databaseandport(default 1433) from the credential config or secret. - Connects with encryption on (off only for localhost) and trusts the server certificate.
- Binds
parametersas named inputs, runssql, closes the connection and returns{ result }with the first record set (an empty array when the statement returns no rows).
In a workflow
The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.
{
"node_id": "node-find-customer",
"label": "Find customer",
"operator_slug": "integrations.microsoft.sqlserver.query",
"operator_version": "1.0.0",
"config": {
"connection_id": "pi-credential-xxxx",
"sql": "SELECT id, email, status FROM customers WHERE id = @id",
"parameters": [
{
"name": "id",
"value": "{{ $json.customer_id }}"
}
]
}
}{
"ok": true,
"data": {
"result": [
{
"id": 42,
"email": "ana@example.com",
"status": "active"
}
]
},
"port": "out"
}Configuration
-
connection_idstring Required -
Credential for your SQL Server / Azure SQL instance. Accepts credentials of type `connection-string` (`Server=...;Database=...;User Id=...;Password=...;`) or `basic-auth` (username + password + server + database).
-
sqlstring Required Accepts expressions -
The SQL statement or stored procedure call to execute (e.g., "SELECT * FROM users WHERE id = @id").
-
parametersarray Optional -
Array of { name, type, value } objects for parameterized query binding.
Behaviour in the code
What the implementation does with these keys beyond what the schema says.
-
parameters - Accepts an array of
{ name, value }or a plain object{ "id": 42 }. Atypefield is ignored: the driver infers the SQL type from the JavaScript value. Names are written without@. -
connection_id - A value containing
;,localhostor127.0.0.1is parsed as inline JSON connection settings and the vault is skipped, so a raw ADO-style connection string placed here fails with a JSON parse error. Store connection strings as aconnection-stringcredential.
Output ports
out default The statement ran. Queries with no rows and statements such as UPDATE also leave here with result: [].
{
"result": [
{
"id": 42,
"email": "ana@example.com",
"status": "active"
}
]
}error Validation, credential resolution, the connection or the statement failed.
{
"error": "Must declare the scalar variable \"@id\"."
}In expressions
What a later node can read from this node's output with $("SQL Server - Query").item.json.<path> (write your node's label instead of SQL Server - Query). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.
| Expression | Editor | Worker |
|---|---|---|
$("SQL Server - Query").item.json.resultArray of rows returned by the query |
Errors
| Message | Port | Cause and fix |
|---|---|---|
connection_id is required | error | No credential in the config or in the incoming item. |
sql query is required | error | sql is empty. |
Credential <connection_id> has unsupported type '<type>' for integrations.microsoft.sqlserver.query. Use 'connection-string' or 'basic-auth'. | error | The credential type is not supported by this node. |
Must declare the scalar variable "@<name>". | error | sql uses a parameter that is not in parameters. |
Login failed for user '<user>'. | error | Wrong user or password in the credential. |
Input contract
-
connection_idstring Required -
sqlstring Required -
parametersarray Optional
Output contract
-
resultarray<object> Optional -
Array of rows returned by the query
Contracts (JSON Schema)
The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.
{
"slug": "integrations.microsoft.sqlserver.query",
"name": "SQL Server - Query",
"category": "integrations",
"group": [
{
"key": "microsoft",
"name": "Microsoft",
"icon_url": "/icons/integrations/microsoft/microsoft.svg"
},
{
"key": "sql-server",
"name": "SQL Server",
"icon_url": "/icons/integrations/microsoft/sql-server.svg"
}
],
"icon_url": "/icons/integrations/microsoft/sql-server.svg",
"version": "1.0.0",
"description": "Execute SQL queries and stored procedures on Microsoft SQL Server databases.\n\n Connect your SQL Server instance (on-premise or Azure SQL) and run parameterized queries with @paramName binding for SQL injection prevention. Supports connection pooling and automatic cleanup.\n\n **Operations:**\n - **SELECT:** Fetch rows from tables with filters, joins, and aggregations.\n - **INSERT:** Add new records to tables.\n - **UPDATE:** Modify existing records matching a condition.\n - **DELETE:** Remove records from tables.\n - **Stored Procedures:** Execute stored procedures with named input parameters.\n - **DDL:** Execute CREATE, ALTER, DROP statements for schema management.",
"capabilities": [
"sql",
"database",
"mssql",
"microsoft",
"azure"
],
"config_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "SQL Server Credential",
"description": "Credential for your SQL Server / Azure SQL instance. Accepts credentials of type `connection-string` (`Server=...;Database=...;User Id=...;Password=...;`) or `basic-auth` (username + password + server + database).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"mssql"
]
}
},
"sql": {
"type": "string",
"title": "SQL Query",
"description": "The SQL statement or stored procedure call to execute (e.g., \"SELECT * FROM users WHERE id = @id\").",
"format": "expression",
"ui_widget": "sql_editor"
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of { name, type, value } objects for parameterized query binding."
}
},
"required": [
"connection_id",
"sql"
]
},
"input_contract_schema": {
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"sql": {
"type": "string"
},
"parameters": {
"type": "array"
}
},
"required": [
"connection_id",
"sql"
]
},
"output_contract_schema": {
"type": "object",
"properties": {
"result": {
"type": "array",
"items": {
"type": "object"
},
"description": "Array of rows returned by the query"
}
}
},
"ports": [
{
"port_id": "out",
"label": "Rows",
"description": "Resulting rows from the query",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
],
"execution_mode": "async",
"required_resources": [],
"compatible_worker_pools": [
"standard-io",
"db-io"
],
"tags": [
"sql",
"database",
"microsoft"
],
"is_stateful": false,
"publisher": {
"identity": "org_sommatic_ai",
"profile": {
"name": "Sommatic AI",
"verified": true,
"url": "https://sommatic.ai",
"logo_url": null
}
}
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string",
"title": "SQL Server Credential",
"description": "Credential for your SQL Server / Azure SQL instance. Accepts credentials of type `connection-string` (`Server=...;Database=...;User Id=...;Password=...;`) or `basic-auth` (username + password + server + database).",
"ui_widget": "connection_picker",
"ui_options": {
"credential_types": [
"connection-string",
"basic-auth"
],
"types": [
"mssql"
]
}
},
"sql": {
"type": "string",
"title": "SQL Query",
"description": "The SQL statement or stored procedure call to execute (e.g., \"SELECT * FROM users WHERE id = @id\").",
"format": "expression",
"ui_widget": "sql_editor"
},
"parameters": {
"type": "array",
"title": "Query Parameters",
"description": "Array of { name, type, value } objects for parameterized query binding."
}
},
"required": [
"connection_id",
"sql"
]
}{
"type": "object",
"properties": {
"connection_id": {
"type": "string"
},
"sql": {
"type": "string"
},
"parameters": {
"type": "array"
}
},
"required": [
"connection_id",
"sql"
]
}{
"type": "object",
"properties": {
"result": {
"type": "array",
"items": {
"type": "object"
},
"description": "Array of rows returned by the query"
}
}
}[
{
"port_id": "out",
"label": "Rows",
"description": "Resulting rows from the query",
"is_default": true,
"supports_condition": true
},
{
"port_id": "error",
"label": "Error",
"description": "Error occurred during execution",
"is_default": false,
"supports_condition": false
}
]Execution
- Execution
async- Stateful
- No
- Credentials
- Resolved on the server from
connection_id; the secret never reaches the workflow. - Capabilities
sqldatabasemssqlmicrosoftazure- Tags
sqldatabasemicrosoft
Notes and limits
- Only the first record set is returned;
rowsAffectedand output parameters are not exposed. AddOUTPUTor a finalSELECTto get values back from a write. - A new connection is opened and closed on every run. The driver's default timeouts apply and the node does not retry.
Reviewed against the orchestrator code · 31e874b · 2026-11-26