SQL Server 定时过程 [英] SQL Server Timed procedure

查看:32
本文介绍了SQL Server 定时过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好的,这是我遇到的一个问题...首先让我说我是 SQL Server 新手.我更像是一名 Web 开发人员,对 MySQL 和 PHP/Ruby 非常满意......尽管我刚刚遇到了 SQL 服务器的问题.

Ok so here is a problem i have...first let me start by saying I am a SQL Server newbie. I am more of a web developer and very much comfortable with MySQL and PHP/Ruby...Though I just got a problem with SQL server thrown my way.

问题来了

我需要在每个月的某个时间(月底前 11:55 和月初 12:05)更新 SQL Server 数据库中的一些表.

I need to update some tables in a SQL Server database at a certain times (11:55 before the end of the month and 12:05 at the beginning of the month) monthly.

例如……

基于每个用户的计算,我需要一个 if then else 数学运算来计算 x 并更新记录 x

Based on a calculation per user i need to have an if then else with math that will do calculation x and update record x

我只需要一种方法来做这些......我正在考虑存储过程或类似的东西,但也许有人可以给我一个更清晰的图片......我需要在结束前的 11:55 运行这个过程本月和月初的 12:05 ......所以一个月两次......任何想法如何做到这一点或最好的工具使用......

I just need the way to do these ...I was thinking of stored procedures or something along those lines but maybe someone can give me a clearer picture...I need to run this procedure at 11:55 before the end of the month and 12:05 at the beginning of the month...so twice a month....any ideas how to do this or the best tool to use....

推荐答案

SQL Server 附带 SQL Server 代理,它允许您安排作业的执行(可以是存储过程).

SQL Server comes with SQL Server Agent, which allows you to schedule execution of Jobs (whch can be stored procedures).

如果您有权限,最简单的方法是编写一个存储过程并使用 SQL Server 代理按您需要的任何时间表执行它.

The simplest approach, if you have the rights, is to write a stored procedure and use SQL Server Agent to execute it on whatever schedule you need.

其他方法包括编写一个外部应用来完成工作,并使用另一种调度机制(例如 Windows 计划任务)来启动外部应用.

Other approaches involve writing an external app to do the work and using another scheduling mechanism (Windows Scheduled Tasks, for example) to launch the external app.

编辑

在我保存这个答案后,我突然想到在 Serverfault.com 上回答这个问题可能更好

After I saved this answer, it occured to me that this question is probably better answered at Serverfault.com

这篇关于SQL Server 定时过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆