开发者

SQL 2008 R2 - Time-Based Triggers?

Is it possible to have a stored procedure or set of SQL code run periodically by specifying a time-based trigger in SQL Server? 开发者_运维技巧


Not directly, but look at SQL Jobs.

A job is a specified series of operations performed sequentially by SQL Server Agent. A job can perform a wide range of activities, including running Transact-SQL scripts, command-line applications, Microsoft ActiveX scripts, Integration Services packages, Analysis Services commands and queries, or Replication tasks. Jobs can run repetitive tasks or those that can be scheduled, and they can automatically notify users of job status by generating alerts, thereby greatly simplifying SQL Server administration.

(emphasis mine)


You can use a SQL Agent job. IF you have a requirement to run on Express editions, that lack SQL Agent, you can use dialog timers and activation.


You can use a SQL job to run any SQL on a schedule. If you are needing to do something a little more dynamic you can control the jobs (creation, scheduling, removing etc) from SQL itself. This provides an immense amount of flexibility.

Some more info on controlling jobs with TSQL here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜