我在Node JS中使用sql server的MSSQL驱动程序进行此查询:
public getDataParameterFirst(SerialNumber, Sid, OreDa, OreA, MinutiDa, MinutiA)
{
return runDb(cnn => cnn.query `SELECT * FROM activeTelemetry.tbl_EHStage WHERE SerialNumber = ${SerialNumber} AND Sid = ${Sid}
AND Day = DATEPART(day, getutcdate()) AND Month = DATEPART(month, getutcdate())
AND Year = DATEPART(year, getutcdate()) AND Hour >= ${OreDa} AND Hour < ${OreA} AND Minute >= ${MinutiA} AND Minute < ${MinutiDa}`
.then( result => { console.dir(result); return result.recordset})
);
}
查询返回:
{ recordsets: [ [] ],
recordset: [],
output: {},
rowsAffected: [ 0 ] }
如果删除
AND Minute >= ${MinutiA} AND Minute < ${MinutiDa}
查询有效。
有人可以帮助我吗?