• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 232
  • Last Modified:

How to call a stored procedure from a function


I'd like to know how / correct syntax I should be using to call a stored procedure in SQL Server from a script function in JavaScript.

The environment I'm working in is Sage CRM however the answer to this question does not appear to need to be specific to any particular software.

  • 2
1 Solution
TartanTaurusAuthor Commented:
Thanks for that,

I have my connection as follows, but when I try to call it, I get an error saying it cannot find stored proc by that name. Any suggestions?


function UpdateRecord()
var connection = new ActiveXObject("ADODB.Connection");
connection.Open("Data Source=localhost\\TabletProject,1433;Provider=SQLOLEDB;User Id=sa;Password=xxxxx;Persist Security Info=True;Initial Catalogue=G41;");
var r = connection.Execute("exec customrefproc");
oppo_customref = r; 

Open in new window


Try using fully qualified name
connection.Execute("exec <your database>.dbo.customrefproc");

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now