msnodesqlv8

Microsoft Driver for Node.js SQL Server compatible with all versions of Node.

msnodesqlv8 downloads msnodesqlv8 version msnodesqlv8 license

msnodesqlv8Similar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on msnodesqlv8's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of msnodesqlv8](https://npm-compare.com/img/npm-trend/THREE_YEARS/msnodesqlv8.png)](https://npm-compare.com/msnodesqlv8#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on msnodesqlv8's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of msnodesqlv8](https://npm-compare.com/img/github-trend/msnodesqlv8.png)](https://npm-compare.com/msnodesqlv8)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
msnodesqlv801501.2 MB21a day agoApache-2.0

README for msnodesqlv8

msnodesqlv8

Build status npm GitHub stars

Native ODBC driver for SQL Server (and Sybase ASE) for Node.js and Electron. Ships prebuilt binaries for Linux, macOS and Windows. Supports BCP, TVP, streaming, Always Encrypted, stored procedures, prepared statements, connection pooling and Windows integrated auth.


Performance

Measured end-to-end over a network (RTT ~3 ms) against SQL Server 2022 on Linux x64, Node v24, ODBC Driver 18. Schema is a 14-column trade record (bigint PK, datetime2, varchar, nvarchar, int, decimal, bit, nullable nvarchar) — a realistic OLTP row, not a narrow best-case table.

OperationRowsMedianThroughput
bulk insert100,000762 ms131k rows/s
bcp insert100,000764 ms131k rows/s
bcp insert10,00077 ms129k rows/s
select (array)100,000891 ms112k rows/s
select (stream)100,000815 ms122k rows/s

Reproduce: node samples/javascript/benchmark.js --rows 1000,10000,100000 --modes bulk,bcp,select. Numbers depend on RTT, schema width and server hardware — use the script to get your own.


Install

npm install msnodesqlv8 --save

Prebuilt binaries are downloaded automatically for Linux (x64, glibc ≥ 2.28 and musl), macOS (x64, arm64) and Windows (x64, ia32). Electron binaries are published alongside Node binaries for current major versions.

You also need a Microsoft ODBC driver on the host:

  • Linux / macOS: ODBC Driver 17 or 18 (18 recommended, required for BCP).
  • Windows: ODBC Driver 17 or 18 via the MSI installer. Older drivers (SQL Server Native Client) still work for non-BCP paths.

Building from source is documented in docs/building-from-source.md.


Quick start

Connect and query

const sql = require('msnodesqlv8')

const cs = 'Driver={ODBC Driver 18 for SQL Server};Server=localhost;' +
           'Database=master;UID=sa;PWD=yourStrong(!)Password;Encrypt=no'

const conn = await sql.promises.open(cs)
const res  = await conn.promises.query('SELECT @@VERSION AS v')
console.log(res.first[0].v)
await conn.promises.close()

Parameterised insert

await conn.promises.query(
  'INSERT INTO trades (id, symbol, qty) VALUES (?, ?, ?)',
  [1, 'AAPL', 100]
)

Bulk insert (the fast path)

const table = await conn.promises.getTable('trades')
await table.promises.insert(rows)          // array-bind, ~130k rows/s
// table.setUseBcp(true)                    // opt-in to native BCP protocol

See samples/javascript/ for runnable versions of every snippet below.


Features

FeatureSampleNotes
Connect + querysimple-demo.jscallback and promise APIs
Streaming resultsstreaming.json('row'), on('column'), pause/resume
Stored proceduresprocedure.jsnamed params, output params, return code
Table-valued parameterstvp.jsbuild TVP from object array
Bulk insert / updatetable-builder.jsBulkTableOpMgr array bind
BCP fast insertbenchmark.jstable.setUseBcp(true) — ODBC 17/18 only
Connection poolsimple-pool.jsbuilt-in, no external dep
Pool scaling strategiespool-scaling.jssee docs/pool-efficient-strategy.md
Prepared statementstest/prepared.test.jsreuse parsed plan across calls
Transactionstxn.jsexplicit begin/commit/rollback
Pause / resume long querypaged-procedure-pause-resume.jsbackpressure for large result sets
Thread workersthread-workers.jsoffload queries to worker_threads
Benchmark harnessbenchmark.jsreproduces the numbers above

Full API reference lives in the wiki.


Standalone example apps

Full runnable projects in their own repos, showing msnodesqlv8 wired into real frameworks. The driver is a native addon — do not call it from a UI thread (renderer process, Next.js client components). Use a server route, API handler or worker.

StackRepo
Next.js (pages router)todo-with-nextjs_msnodesqlv8
Next.js (app router)todo-with-nextjs-app-router_msnodesqlv8
Vite + Expressmsnodesqlv8-vite
TypeScriptmsnodesqlv8_ts_sample
JavaScript with IDE typingsmsnodesqlv8_yarn_sample
Sequelizemsnodesqlv8-sequelize
mssql package over this drivermsnodesqlv8_mssql_sample
Electronmsnodesqlv8-electron
Reactmsnodesqlv8-react

Platform support

PlatformArchNodeElectron
Linux (glibc ≥ 2.28)x6420, 22, 2432+
Linux (musl / Alpine)x6420, 22, 2432+
macOSx64, arm6420, 22, 2432+
Windowsx64, ia3220, 22, 2432+
Windows Integrated Authx64supported via Trusted_Connection=yes—

Tested against SQL Server 2017, 2019, 2022. Sybase ASE support is smaller in scope — see samples/javascript/sybase-query.js and the wiki.


Troubleshooting

IM002: Data source name not found — no matching ODBC driver installed. On Linux/macOS check odbcinst -q -d. On Windows check ODBC Data Sources (64-bit).

SSL Provider: certificate verify failed on newer SQL Server — add Encrypt=yes;TrustServerCertificate=yes to the connection string, or install the server certificate.

Segfault on Ubuntu/Debian with Node 18/20 — requires OpenSSL 3.2. See tool/openssl.sh in this repo and the wiki install notes.

BCP crashes or silently falls back — BCP requires ODBC Driver 17 or 18 exactly. Any older driver (SQL Server Native Client, FreeTDS) will either crash the process or silently no-op. Check with odbcinst -q -d.

Prebuilt binary fails to load — your glibc, Node ABI or Electron version may not match a published binary. Try building from source: docs/building-from-source.md.

More issues and workarounds: GitHub Issues.


Links

License

Apache 2.0. See LICENSE.txt.