Ashish Yadav Ashish Yadav - 1 year ago 92
Node.js Question

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

I am using 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

Answer Source
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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download