I am changing my application's database from MySQL to MSSQL. I send parameters like below for MySQL database.
var sql = require('./db.js');
sql.query("select * from table where field1 = ? or field2 = ? ", [field1val, field2val], function (error, results) {
if(error){
//handle error
}
else{
//handle the results
}
}
How to do this in MSSQL or is it even possible to do this way? (I am using mssql
module).
The stored procedure is the only way to achieve it? If so, how to do that in Nodejs mssql module?
What is the best practice to run a query in SQL server if we can't send parameter (which escapes the string in mysql automatically)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…