如何自定义sql server代理作业

发布于 2024-07-08 03:34:05 字数 111 浏览 3 评论 0原文

我需要能够在每月 10 日安排一项作业,并让它运行指定的天数或直到指定的日期。

有没有办法使用某种 API 或其他东西来自定义 sql server 代理作业?

谢谢。

I need to be able to schedule a job on the 10th of each month and have it run for a set number of days or until a specified date.

Is there any way to customize sql server agent jobs using some sort of API or something?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

无法回应 2024-07-15 03:34:07

我仍然找不到任何自定义作业计划的方法,但我通过向作业步骤添加条件找到了解决方法:

IF (DAY(GetDate()) >= 10)
执行MySP

并设置每天运行的时间表。

I still can't find any way of customizing the job schedule, but I have figured a way around it by adding the condition to the job step:

IF (DAY(GetDate()) >= 10)
EXEC MySP

And setting the schedule to run every day.

追星践月 2024-07-15 03:34:06

您可以通过对作业使用多个计划来使用 SQL 作业计划属性。 您可以安排作业在该月的 10 天运行(可以选择结束日期)。 然后,您可以创建多个计划,一个用于 11 日、12 日等。

You can accomplish using the SQL Job Schedule properties by using more than one schedule for the job. You can schedule the job to run on the 10th day of the month (with the option for an end date). You can then create multiple schedules, one for the 11th, 12th, etc.

深陷 2024-07-15 03:34:06

SQL Server 代理没有您需要的计划选项,因此我认为您的解决方法是将其保留在 SQL Server 中的最佳方法。

然而,Windows 任务计划程序确实可以选择在该月的“x”天运行作业,也许通过 Windows 任务计划程序使用 sqlcmd 启动存储过程是另一种解决方案?

希望这可以帮助

The SQL Server Agent does not have a schedule option like you need, so I think your workaround is as good as it gets for keeping it inside SQL Server.

The Windows Task Scheduler however does have an option to run a job on the 'x' day of the month, maybe kicking your sproc off using sqlcmd via Windows Task Scheduler is an alternate solution?

Hope this helps

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文