{"action":"created","issue":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/111","labels_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/111/comments","events_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/111/events","html_url":"https://github.com/patriksimek/node-mssql/issues/111","id":54499317,"number":111,"title":"Can't get access to output parameter","user":{"login":"XemsDoom","id":1385611,"avatar_url":"https://avatars.githubusercontent.com/u/1385611?v=3","gravatar_id":"","url":"https://api.github.com/users/XemsDoom","html_url":"https://github.com/XemsDoom","followers_url":"https://api.github.com/users/XemsDoom/followers","following_url":"https://api.github.com/users/XemsDoom/following{/other_user}","gists_url":"https://api.github.com/users/XemsDoom/gists{/gist_id}","starred_url":"https://api.github.com/users/XemsDoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XemsDoom/subscriptions","organizations_url":"https://api.github.com/users/XemsDoom/orgs","repos_url":"https://api.github.com/users/XemsDoom/repos","events_url":"https://api.github.com/users/XemsDoom/events{/privacy}","received_events_url":"https://api.github.com/users/XemsDoom/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-01-15T20:23:57Z","updated_at":"2015-01-15T21:08:07Z","closed_at":null,"body":"Hey Patrik,\r\nI am currently rewriting a project into a Nodejs app from PHP. I am facing a problem when trying to get an id of a stored procedure back into the app.\r\n\r\nThe recordsets or the return value are empty or 0. The execution of the procedure in the \"SQL Management Studio\" returns the correct id when executing manually.\r\n\r\n![image](http://puu.sh/eyZmb/2667598c71.png)\r\n\r\n\r\nThis is the test code I tried to use:\r\n```\r\n\tvar adq = new sql.Request();\r\n\tadq.input('documentName', sql.VarChar(255), \"1234\");\r\n\tadq.input('displayOrder', sql.Int, 0);\r\n\tadq.input('lastModified', sql.VarChar(255), getDateNow());\r\n\tadq.input('downloadAmount', sql.Int, 0);\r\n\tadq.input('tags', sql.VarChar(255), \"1,2,3\");\r\n\tadq.input('active', sql.Bit, 1);\r\n\tadq.output('documentID', sql.Int);\r\n\tadq.execute('createDocument', function(err, recordsets, returnValue){\r\n\t\tconsole.log(err);\r\n\t\tconsole.log(recordsets);\r\n\t\tconsole.log(returnValue);\r\n\t\tres.send(recordsets.toString());\r\n\t});\r\n```\r\n\r\nThere are no errors, but I simply can't find any way to access the @documentID output parameter.\r\n\r\nerr -> undefined\r\nrecordsets -> [ returnValue: 0 ]\r\nreturnValue -> 0\r\n\r\nThis is the stored procedure code:\r\n\r\n```\r\nUSE [dms]\r\nGO\r\nSET ANSI_NULLS ON\r\nGO\r\nSET QUOTED_IDENTIFIER ON\r\nGO\r\nALTER PROCEDURE [dbo].[createDocument]\r\n\t@documentName VARCHAR(255),\r\n\t@displayOrder INT,\r\n\t@lastModified VARCHAR(255),\r\n\t@downloadAmount INT,\r\n\t@tags VARCHAR(255),\r\n\t@active BIT,\r\n\t@documentID INT OUTPUT\r\nAS\r\nBEGIN\r\n\tSET NOCOUNT ON;\r\n\tINSERT INTO document (document_name, display_order, download_amount, tags, active, last_modified) VALUES (@documentName, @displayOrder, @downloadAmount, @tags, @active, @lastModified); \r\n\tSELECT @documentID = SCOPE_IDENTITY();\r\nEND\r\n```\r\n\r\nAny idea what to do or I am totally not getting what output parameters are for?"},"comment":{"url":"https://api.github.com/repos/patriksimek/node-mssql/issues/comments/70161850","html_url":"https://github.com/patriksimek/node-mssql/issues/111#issuecomment-70161850","issue_url":"https://api.github.com/repos/patriksimek/node-mssql/issues/111","id":70161850,"user":{"login":"patriksimek","id":1000058,"avatar_url":"https://avatars.githubusercontent.com/u/1000058?v=3","gravatar_id":"","url":"https://api.github.com/users/patriksimek","html_url":"https://github.com/patriksimek","followers_url":"https://api.github.com/users/patriksimek/followers","following_url":"https://api.github.com/users/patriksimek/following{/other_user}","gists_url":"https://api.github.com/users/patriksimek/gists{/gist_id}","starred_url":"https://api.github.com/users/patriksimek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/patriksimek/subscriptions","organizations_url":"https://api.github.com/users/patriksimek/orgs","repos_url":"https://api.github.com/users/patriksimek/repos","events_url":"https://api.github.com/users/patriksimek/events{/privacy}","received_events_url":"https://api.github.com/users/patriksimek/received_events","type":"User","site_admin":false},"created_at":"2015-01-15T21:08:07Z","updated_at":"2015-01-15T21:08:07Z","body":"Please see the docs here: https://github.com/patriksimek/node-mssql#executeprocedure-callback\r\n\r\nOutput values are accessible trough `request.parameters` collection. In your case you should use `request.parameters.documentID.value`."}}