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.

Who is Participating?
elimesikaConnect With a Mentor Commented:

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

Open in new window

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

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.

All Courses

From novice to tech pro — start learning today.