Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Way to access a REST Service via a SQL Server stored procedure?

We are looking for a way to call a REST service from a SQL Server 2008 & newer stored procedure. We do not need to get any information from this service. We just need to force the call to run in the middle of a stored procedure.

I have found some 3rd party options or CLR; but I refuse to think there isn't an easier way since we just need to fire a call and don't need anything in return.

Hopefully someone can shed some light. Thanks!

like image 667
RandomlyOnside Avatar asked Feb 13 '23 08:02

RandomlyOnside


1 Answers

You could make a SQL Agent job to run a PowerShell script, then run the job via msdb.dbo.sp_start_job. That way you wouldn't need any external scripts or utilites, nor any SQL-CLR.

Your job step would be something like:

$request = [System.Net.WebRequest]::Create('http://stackoverflow.com/')
$result = $request.GetResponse()
like image 103
dpw Avatar answered Feb 15 '23 06:02

dpw