从 SQL Server 中的存储过程调用 URL?

问题描述:

只是想知道是否可以从存储过程调用 URL(最终将该过程添加到 sql 作业)当网页刷新我的数据库时,如果我能自动执行此过程就太好了.

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.

我希望能够从存储过程请求网页.在所需网页的页面加载上,有一个功能可以刷新我的数据库.我希望它每天凌晨 4 点刷新我的数据库.为了让我不要在凌晨 4 点(还在睡觉)手动进入网站,我需要为我做其他事情.我认为 sql 工作会很棒,因为我可以设置时间并完成工作.我不太了解 PowerShell,想知道我是否可以请求 URL,或者使用存储过程或任何其他方式访问 url.

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.

您可以使用任务计划程序(Windows 的一部分)来完成.只需创建一个计划任务,打开 Internet Explorer 并浏览到该页面:

You can do it with Task Scheduler (part of Windows). Just create a scheduled task that opens Internet Explorer and browses to the page:

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

或者对于 64 位 Windows:

Or for 64-bit Windows:

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

或者,使用 SQL Server 代理创建作业,并使用上述命令创建类型为操作系统 (CmdExec)"的单个步骤.

Alternatively, create a job using SQL Server Agent, and create a single step of type "Operating System (CmdExec)" with the above command.