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.
只是想知道是否可以从存储过程中调用URL(最终将该过程添加到sql作业)当网页刷新我的数据库时,如果我可以自动执行此过程,那将是非常好的。
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.
我希望能够通过商店程序请求网页。在所需网页的页面加载中,有一个刷新我的数据库的功能。我希望它每天凌晨4点刷新我的数据库。为了让我不要在凌晨4点手动上网(还在睡觉),我还需要别的东西给我。我认为sql工作会非常好,因为我可以设置时间和工作。我不太了解PowerShell,并想知道我是否可以请求URL,或使用存储过程或任何其他方式访问URL。
3 个解决方案
#1
4
You can do it with Task Scheduler (part of Windows). Just create a scheduled task that opens Internet Explorer and browses to the page:
您可以使用任务计划程序(Windows的一部分)执行此操作。只需创建一个打开Internet Explorer并浏览到该页面的计划任务:
"C:\Program Files\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"
Or for 64-bit Windows:
或者对于64位Windows:
"C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"
Alternatively, create a job using SQL Server Agent, and create a single step of type "Operating System (CmdExec)" with the above command.
或者,使用SQL Server代理创建作业,并使用上述命令创建“操作系统(CmdExec)”类型的单个步骤。
#2
5
I'm pretty sure MS SQL doesn't allow you to do that directly.. obvious security issues. However, I think you can get around it by using xp_cmdshell to execute a vbscript file and in that file, create an xmlhttp request to a site.
我很确定MS SQL不允许你直接这样做..明显的安全问题。但是,我认为您可以通过使用xp_cmdshell执行vbscript文件来解决它,并在该文件中,为站点创建xmlhttp请求。
xp_cmdshell command:
xp_cmdshell命令:
EXEC master..xp_cmdshell 'c:\<file>.vbs',no_output
VBScript:
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
EDIT
编辑
In response to a comment on how to do this asynchronously.
回应关于如何异步执行此操作的注释。
xp_cmdshell command:
xp_cmdshell命令:
EXEC master..xp_cmdshell 'c:\caller.vbs',no_output
VBScript for caller:
调用者的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
#3
3
@newurl is url you want to hit @response is response you received
@newurl是你要点击的网址@response是你收到的回复
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
#1
4
You can do it with Task Scheduler (part of Windows). Just create a scheduled task that opens Internet Explorer and browses to the page:
您可以使用任务计划程序(Windows的一部分)执行此操作。只需创建一个打开Internet Explorer并浏览到该页面的计划任务:
"C:\Program Files\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"
Or for 64-bit Windows:
或者对于64位Windows:
"C:\Program Files (x86)\Internet Explorer\iexplore.exe" "http://yoursite.com/yourpage.aspx"
Alternatively, create a job using SQL Server Agent, and create a single step of type "Operating System (CmdExec)" with the above command.
或者,使用SQL Server代理创建作业,并使用上述命令创建“操作系统(CmdExec)”类型的单个步骤。
#2
5
I'm pretty sure MS SQL doesn't allow you to do that directly.. obvious security issues. However, I think you can get around it by using xp_cmdshell to execute a vbscript file and in that file, create an xmlhttp request to a site.
我很确定MS SQL不允许你直接这样做..明显的安全问题。但是,我认为您可以通过使用xp_cmdshell执行vbscript文件来解决它,并在该文件中,为站点创建xmlhttp请求。
xp_cmdshell command:
xp_cmdshell命令:
EXEC master..xp_cmdshell 'c:\<file>.vbs',no_output
VBScript:
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
EDIT
编辑
In response to a comment on how to do this asynchronously.
回应关于如何异步执行此操作的注释。
xp_cmdshell command:
xp_cmdshell命令:
EXEC master..xp_cmdshell 'c:\caller.vbs',no_output
VBScript for caller:
调用者的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
#3
3
@newurl is url you want to hit @response is response you received
@newurl是你要点击的网址@response是你收到的回复
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