Registry / database / node-red-contrib-mssql

node-red-contrib-mssql

JSON →
library0.0.7jsnpmunverified

A Node-RED contrib node for connecting to Microsoft SQL Server and Azure SQL databases. Current version 0.0.7 (stable) uses the mssql npm package and provides pre-built Linux TDS drivers, eliminating the need for system-level ODBC setup. It offers a visual node for query execution and connection management within Node-RED flows, with basic configuration for server, database, authentication, and TLS. Released under RedConnect, it targets Node-RED users requiring fast, driver-free SQL Server integration.

npm install node-red-contrib-mssql
INSTALL
IMPORT
SIG · NODE-RED-CONTRIB-M
N
node-red-contrib-mssql
databasejavascriptv0.0.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

node-red-contrib-mssql
Install via Node-RED palette manager or npm install node-red-contrib-mssql
npm install node-red-contrib-mssql
This is a Node-RED contrib node, not a regular npm package. It is loaded automatically by Node-RED after installation. No manual require() or import.
mssql connection
Configure via Node-RED UI (server config node)
import { Connection } from 'node-red-contrib-mssql'
Connections are managed via Node-RED's config nodes. No direct JS import of the package's internals.
Query execution
Use the mssql node in a flow with msg.payload as SQL query
const mssql = require('node-red-contrib-mssql'); mssql.query(...)
The package provides Node-RED nodes; interactions occur via flow messages, not code calls.

Shows how to configure and use the MSSQL node in Node-RED, including server config and query execution.

// No code example as this is a Node-RED node. // In Node-RED, drag a mssql node to the workspace. // Configure a new mssql server config node with: // Server: your-server.database.windows.net // Port: 1433 // Database: your-db // Authentication: SQL Login // Username: user // Password: pass // Encrypt: true (for Azure) // In the mssql node, set Query mode to 'msg.payload' (default). // Connect an inject node with payload set to 'SELECT * FROM table'. // Deploy and inject.
Debug
Known issues
breakingPre-built Linux drivers only: The package ships compiled TDS drivers for Linux x86_64. Windows and macOS users may need to install additional dependencies or use Docker.
fix
Use a Linux environment (or Docker) for native support, or manually install unixODBC and set up drivers on other OSes.
affects: >=0.0.1
gotchaQuery mode defaults to 'msg.payload' but many users expect a fixed query in the node config. Not setting the query mode correctly results in 'undefined query' errors.
fix
Set the query mode to 'fixed' and provide the SQL query in the node configuration, or ensure msg.payload contains the query string.
affects: >=0.0.1
deprecatedThe mssql package version used may be outdated; check compatibility with recent Node.js versions (v14+). No releases since 2020.
fix
Pin Node.js to v12 or use an alternative like node-red-contrib-mssql-plus.
affects: >=0.0.1
gotchaIf the SQL query fails, the error message may be generic (e.g., 'Request error: ...'). Debugging requires inspecting Node-RED debug output.
fix
Wrap SQL queries in TRY-CATCH or use Node-RED catch nodes to handle errors gracefully.
affects: >=0.0.1
Errors
Common errors & fixes
Error: ConnectionError: Failed to connect to localhost:1433 - connect ECONNREFUSED
SQL Server not running or port blocked on the target host.
fix
Start SQL Server service and ensure the port is reachable (telnet <host> 1433).
Error: ConnectionError: Login failed for user 'sa'. (mssql) { [Error: Login failed for user 'sa'.] name: 'ConnectionError' }
Invalid credentials or SQL Server authentication mode not set to SQL Server and Windows Authentication.
fix
Verify the username/password. Ensure SQL Server has 'SQL Server and Windows Authentication mode' enabled (properties -> Security).
Error: TypeError: Cannot read property 'length' of undefined
Query mode set to 'msg.payload' but msg.payload is undefined.
fix
Provide a SQL query in msg.payload from an inject node or change query mode to 'fixed' and enter the query in the config.
Upgrade
Version history
0.0.7latest on npm
Audit
Dependencies
mssqlrequiredCore SQL Server client library for Node.js; provides TDS protocol handling and connection pooling.
Agent activity
5 hits · last 30 days
node
4
Resources
node-red-contrib-mssql — npm install node-red-contrib-mssql · libregistry