How do I send a list of values from Node.js to a SQL stored procedure?
Loading
How do I send a list of values from Node.js to a SQL stored procedure?
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Abhishek YadavPosted Dec 30, 2025, 7:09 AM
You can’t pass an array directly to a SQL Server stored procedure from Node.js. Use one of these standard approaches:
1. Comma-separated string
Pass the list as a string and split it in SQL using
STRING_SPLIT.Simple but not ideal for large lists.
2. Table-Valued Parameter (recommended)
Create a table type in SQL, accept it as a READONLY parameter in the stored procedure, and send a
sql.Tablefrom Node.js.This is the safest and most performant approach.
3. JSON
Send the list as JSON and parse it in SQL using
OPENJSON.Useful if you need to pass complex structures.
For production and large datasets, Table-Valued Parameters are the correct solution.