使用内联查询时,与执行存储过程时得到的结果集不同。通过该过程调用,记录集被包装到数组内部的数组中,但是使用connection.query
进行内联查询只能得到一个数组级别。
要执行存储过程,请运行:
var conn = new sql.Connection(dbConfig);
var sqlReq = new sql.Request(conn);
sqlReq.execute('getAllServices', function (err, data) {})
它返回:
[ [ { ServiceID: 3,
ServiceName: 'Test',
Charge: 0,
ChargeValidity: 0,
VisibleOnPrescription: true },
{ ServiceID: 4,
ServiceName: 'MRI',
Charge: 0,
ChargeValidity: 0,
VisibleOnPrescription: true } ],
returnValue: 0 ]
要执行内联查询,请运行:
var conn = new sql.Connection(dbConfig);
var sqlReq = new sql.Request(conn);
sqlReq.query('select * from service', function (err, data) {})
这将返回:
[ { ServiceID: 3,
ServiceName: 'Test',
Charge: 0,
ChargeValidity: 0,
VisibleOnPrescription: true },
{ ServiceID: 4,
ServiceName: 'MRI',
Charge: 0,
ChargeValidity: 0,
VisibleOnPrescription: true } ]