Reputation: 6227
I'm using the mssql node package to perform queries on a SQL Server DB. Now I want to pass in an array of intergers to the query string. So I grab The array from req.query.rids and the values output are as follows:
var RIDS = JSON.parse(req.query.rids);
logger.info(`${RIDS}`) // result shows: 204294,204303,104354
But when I use the IN
operator to check for a match to any of the array values. I get the error error: Incorrect syntax near '204294'.
What I understand from this is that the RID array being passed in is not in the correct format for the query.
Question:
How do I pass in an array into mssql query string? `
This is a snippet of the query where I check for a match in the RIDS array:
Left Join [Metrics_DB].[dbo].[AssetBundle]
on [Metrics_DB].[dbo].[Assetdata].RID=[Metrics_DB].[dbo].[AssetBundle].[RID]
where [Asset Sunset Date] is not null and [OSM_Metrics_DB].[dbo].[Assetdata].RID IN ${RIDS}
Upvotes: 0
Views: 245