I think the table I'm trying to query isn't normalized (not my dataset). Whenever my where clause includes a value that is not a number I get the error below. It's as if the value of the where clause is confused with the column name itself. Now if I change the column to a field that only contains numbers, it executes without error. Any idea as to why this is happening?
name: 'ERROR',
event: 'errorMessage',
number: 207,
state: 1,
class: 16,
message: "Invalid column name 'somestring'.",
serverName: 'server1234\\SQLEXPRESS',
procName: '',
lineNumber: 1
var express = require('express');
var app = express();
app.get('/', function (req, res) {
var sql = require("mssql");
// config for your database
var config = {
user: 'username',
password: 'password',
server: 'server1234',
database: 'dbname1234'
};
// connect to your database
sql.connect(config, function (err) {
if (err) console.log(err);
// create Request object
var request = new sql.Request();
// query to the database and get the records
request.query('select * from dbo.recordset3 where column4=somestring', function (err, recordset) {
if (err) console.log(err)
// send records as a response
res.send(recordset);
});
});
});
var server = app.listen(5000, function () {
console.log('Server is running..');
});```
request.query('select * from dbo.recordset3 where column4="somestring"', function (err, recordset) {