node js exceute mssql queries code example
Example: mssql query node js
const sql = require('mssql')
const query=`select * from table`;
config = {
database: "dbname",
options: {
enableArithAbort: true,
encrypt: true,
rowCollectionOnRequestCompletion: false,
},
parseJSON: true,
password: "password",
port: port,
server: "server ip or name",
user: "usenme",
};
sql.on('error', err => {
})
sql.connect(config).then(pool => {
return pool.request()
.query(query)
}).then(result => {
console.log(result.recordset)
}).catch(err => {
console.log(err)
});