Skip to content

request.output + OUTPUT clause returns value in recordset field instead of output field #1562

Description

@RicardoAALL

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions