Skip to content

SQL Server Query

The SQL Server Query module allows executing SQL queries on Microsoft SQL Server (MSSQL) databases. It supports dynamic variables in the query and custom timeout configuration. It uses the mssql library for the connection with encryption disabled by default and trusted server certificates. It is ideal for integrations with enterprise systems that use SQL Server as their database.

ParameterTypeRequiredDescription
credentials_idcredentialsYesSQL Server connection credentials
querycodeYesSQL query to execute (supports {{variable}} variables)
timeoutnumberNoMaximum wait time in milliseconds (default: 30000)

The credential must contain the fields:

  • host: SQL Server address (server field in the connection)
  • user: Database user
  • password: User password
  • database: Database name
  • port: Connection port (default: 1433)
{
"nextModule": "siguiente_modulo",
"data": [
{ "id": 1, "nombre": "Ejemplo", "estado": "activo" }
]
}
{
"credentials_id": "cred_mssql_01",
"query": "SELECT TOP 100 * FROM dbo.Clientes WHERE Activo = 1",
"timeout": 30000
}

When a {{field}} variable contains a text value with single quotes (e.g. Monte Sant'Angelo), the engine automatically escapes the ' character by doubling it ('') before inserting it into the query. This follows the ANSI SQL standard and prevents syntax errors in SQL Server.

-- Input data: store = "Monte Sant'Angelo"
-- Node template:
INSERT INTO [dbo].[Stores] (name) VALUES ('{{store}}')
-- Executed SQL (automatic escaping):
INSERT INTO [dbo].[Stores] (name) VALUES ('Monte Sant''Angelo')

Important: SQL Server does not have a QUOTE() function (it is MySQL-specific). Simply use '{{field}}' and the engine handles the escaping.

Numeric values do not need quotes in the template and are not escaped: use {{price}} without quotes for numeric columns.

  • Supports dynamic variables {{variable}} in the SQL query
  • Text values with single quotes are automatically escaped (' → '') — no manual handling required
  • The result is returned as result.recordset (array of objects)
  • The connection is configured with encrypt: false and trustServerCertificate: true by default
  • The connection is automatically closed on completion (finally block)
  • In case of SQL error, the executed query is included in the error message
  • Timeout is configurable and defaults to 30 seconds
  • sqlQuery (MySQL queries)
  • sqlQueryPostgres (PostgreSQL queries)
  • sqlQueryPostgresSSL (PostgreSQL queries with SSL)
  • sqlQueryOracle (Oracle queries)