Perhaps, I'm misunderstanding how the output method works but here is the code I am using:
Executing the following code
const fullName = "bob smith"
let inserted = await sql.connect(sqlConfig).request()
.input('FullName', sql.NVarChar(255), fullName)
.output('ID', sql.Int)
.query(`
INSERT INTO test.dbo.test_table(FullName)
OUTPUT INSERTED.ID
VALUES(@FullName)
`)
console.log(inserted)
Expected behaviour:
I expected the value returned to be accessed using:
inserted.output
Actual behaviour:
In order to actually access the output value I have to use the recordset field:
inserted.recordset[0].ID
The output field does show the ID property but the value is set to null.
Configuration:
// basic config from example
Software versions
- NodeJS: 18+
- node-mssql: 10.0.1
- SQL Server: 2019
Perhaps, I'm misunderstanding how the output method works but here is the code I am using:
Executing the following code
Expected behaviour:
I expected the value returned to be accessed using:
inserted.outputActual behaviour:
In order to actually access the output value I have to use the recordset field:
inserted.recordset[0].IDThe output field does show the ID property but the value is set to null.
Configuration:
Software versions