Calling a URL from a stored procedure in SQL Server?

Just wondering if it is possible to call the URL from a stored procedure (eventually adding this procedure to the SQL job) Since the web page is updating my database, it would be great if I could automate this process.

Edit:

I want to be able to request a webpage from a storage procedure. There is a function on the download page of the desired web page that updates my database. I want him to update my database at 4 a.m. every day. So that I cannot manually go to the site at 4 a.m. (still asleep), I need to do something else for me. I thought sql work would be great as I can set the time and work. I do not know PowerShell very well and wanted to know if I can request a URL or visit the URL using a stored procedure or in any other way.

+5
source share
3 answers

( Windows). , Internet Explorer :

"C:\Program Files\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"

64- Windows:

"C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"

SQL Server " (CmdExec)" .

+4

, MS SQL . . , , , xp_cmdshell vbscript , xmlhttp .

xp_cmdshell:

EXEC master..xp_cmdshell 'c:\<file>.vbs',no_output  

VBScript:

call main()
sub main()
    Dim xmlHTTP, url
    Set xmlHTTP = WScript.CreateObject("Msxml2.XMLHTTP")
    url = "<url>"
    xmlHTTP.Open "GET", url, False
    xmlHTTP.Send  ""
end sub 

, .

xp_cmdshell:

EXEC master..xp_cmdshell 'c:\caller.vbs',no_output

VBScript :

call main()
sub main()
    Dim scmd
    Set scmd = "c:\windows\system32\cscript.exe //nologo c:\<originalVBS>.vbs"
    createobject("wscript.shell").run scmd,0,false
end sub
+5

@newurl is the URL you want @response to click on - the answer you got

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
+3
source

All Articles