简体   繁体   中英

How to execute stored procedure as well as select command using nodejs-mssql

I am using node-mssql ( https://github.com/patriksimek/node-mssql ) node module to connect my SQL Server.

I have requirement some thing like

declare @isTrue int
exec @isTrue = sp_isFolderExist @name='new folder',@FolderTypeID=1
select @isTrue

How to execute this stored procedure and get the value of the isTrue variable?

var sql = require('mssql');

sql.connect("mssql://username:password@localhost/database", function(err) {
    // ... error checks

    new sql.Request()
    .input('name', 'new folder')
    .input('FilterTypeID', 1)
    .execute('sp_isFolderExist', function(err, recordsets, returnValue) {
        // ... error checks

        console.log(returnValue); // your isTrue value
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM