How do I send a list of values from Node.js to a SQL stored procedure?
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Abhishek YadavRank #217 · 11.3K reputationPosted Dec 30, 2025, 2:09 AM EST
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.