On this page
Sommatic Docs
Open portal

SQL Server - Query

Execute SQL queries and stored procedures on Microsoft SQL Server databases.

View as Markdown
Open in
Integrations Available integrations.microsoft.sqlserver.query Version 1.0.0 Execution: async

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

  1. Resolves the expressions of the node config. Empty connection_id, sql and parameters fall back to the field of the same name in the incoming item.
  2. Resolves the credential on the server: a connection-string credential is passed to the driver as is; a basic-auth / object credential uses username (or user), password, server or host, database and port (default 1433) from the credential config or secret.
  3. Connects with encryption on (off only for localhost) and trusts the server certificate.
  4. Binds parameters as named inputs, runs sql, 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 }}"
      }
    ]
  }
}

Configuration

connection_id string 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).

sql string Required Accepts expressions

The SQL statement or stored procedure call to execute (e.g., "SELECT * FROM users WHERE id = @id").

parameters array 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 }. A type field is ignored: the driver infers the SQL type from the JavaScript value. Names are written without @.
connection_id
A value containing ;, localhost or 127.0.0.1 is 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 a connection-string credential.

Output ports

out default

The statement ran. Queries with no rows and statements such as UPDATE also leave here with result: [].

Data
{
  "result": [
    {
      "id": 42,
      "email": "[email protected]",
      "status": "active"
    }
  ]
}
error

Validation, credential resolution, the connection or the statement failed.

Data
{
  "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.

ExpressionEditorWorker
$("SQL Server - Query").item.json.resultarray= […] (1)Array 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_id string Required
sql string Required
parameters array Optional

Output contract

result array<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
    }
  }
}

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; rowsAffected and output parameters are not exposed. Add OUTPUT or a final SELECT to 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

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs