SQL: cURL calls::

Posted on 2013-06-20
Last Modified: 2013-06-20
Hello team,

Is it possible to call cURL http/s calls from within sql server 2008 using TSQL?
> are there prerequisites and what are those
>do I need to install PHP or some client / modules/etc in order to run the curl command line statements
>what are pros and cons of using

One of our third parties have provided us with the API routines but before I start my questionings them wanted to get an idea from you guys first and see what you think.

Question by:John Esraelo
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
LVL 83

Accepted Solution

Dave Baldwin earned 500 total points
ID: 39263515
While PHP has cURL builtin, there is also a command line version of cURL that you can install on your machine.  You do have to have one of them installed.  PHP requires a web server while cURL runs from the command line.  Come to think of it, you can run PHP from the command line too if you want to.

If you can run 'system' or 'exec' commands from TSQL, then you should be able to run either of those programs.
LVL 12

Expert Comment

ID: 39263524
I'm sorry for sounding abrasive, but applications are responsible for communication between data stores...not the data stores themselves.

So, if your third party has provided you with an API, then they are expecting that you will create or have a supporting application in place that will provide the desired calls out to the remote service.


Author Comment

by:John Esraelo
ID: 39263921
sql server can actually make an xp_cmdshell execution if I am not mistaken.  However, I am not sure about the rest of it and that is something that I would probably need to communicate with them, but, here today, I wanted to get a general thoughts here and collect knowledge.
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.


Author Comment

by:John Esraelo
ID: 39263926

I believe you are on the money.  I have tried something and did work in tsql. However, for some reason I am getting auth failure and working on that right now .

Author Closing Comment

by:John Esraelo
ID: 39263931
Thank you Dave.
LVL 12

Expert Comment

ID: 39263987
The only reason I stated what I did, was because database servers should be strictly just that. In a proper n-tier architecture, database servers should never take on the load of handling cross domain communications. Not even intra-domain communications, except in very limited circumstances.

The application layer is wholly responsible for all aspects of data transportation. Just because a database server supports that functionality certainly does not justify breaking best-practices in favor of using it.

I can understand SQL Server's ability to ACCEPT remote calls as the end result is a formatted dataset, but to make outgoing calls just totally goes against the grain of the intended design of a database server.

I wish you luck if this setup is to be used in any level of enterprise capacity.

LVL 83

Expert Comment

by:Dave Baldwin
ID: 39264099
I tend to agree with Adrian.  Although it is doable, I don't think it is a particularly good idea and I would always use cURL from my application, not my database.

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

751 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question