Solved

SQL: cURL calls::

Posted on 2013-06-20
7
2,100 Views
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.
thx

JohnE
0
Comment
Question by:John Esraelo
  • 3
  • 2
  • 2
7 Comments
 
LVL 83

Accepted Solution

by:
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.  http://curl.haxx.se/  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.
0
 
LVL 12

Expert Comment

by:adrian_brooks
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.

~AB
0
 

Author Comment

by:John Esraelo
ID: 39263921
Adrian,
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.
0
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.

 

Author Comment

by:John Esraelo
ID: 39263926
Dave,

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 .
0
 

Author Closing Comment

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

Expert Comment

by:adrian_brooks
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.

~AB
0
 
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.
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

920 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now