使用Node js中的参数进行查询返回空记录集

时间:2018-03-26 11:26:27

标签: javascript sql-server node.js node-mssql

我在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}

查询有效。

有人可以帮助我吗?

0 个答案:

没有答案