Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling a URL from a stored procedure in SQL Server?

Just wondering if its possible to call a URL from a stored procedure (eventually adding that procedure to a sql job) As the webpage refreshes my database, it would be excellent if I could automate this process.

Edit:

I want to be able to request a webpage from a store procedure. On the page load of the desired webpage there is a function that refreshes my database. I want it to refresh my database at 4 am every day. In order for me not to manually go onto the site at 4am (still sleeping) I need something else to do it for me. I thought sql jobs would be excellent, as I can set the time, and the job up. I don't know PowerShell all that well, and wanted to know if I could request a URL, or visit a url using a stored procedure or any other way.

like image 580
Spooks Avatar asked Jan 25 '11 20:01

Spooks


1 Answers

@newurl is url you want to hit @response is response you received

EXEC Sp_oacreate  'MSXML2.XMLHTTP',@obj OUT;
EXEC Sp_oamethod @obj,'open',NULL,'get',@newurl,'false'
EXEC Sp_oamethod @obj,'send'
EXEC Sp_oamethod @obj,'responseText',@response OUTPUT   
EXEC Sp_oadestroy @obj
like image 156
user6168486 Avatar answered Sep 30 '22 03:09

user6168486