SQL 2008 R2 - Time-Based Triggers?

人盡茶涼 提交于 2019-12-01 04:24:32

问题


Is it possible to have a stored procedure or set of SQL code run periodically by specifying a time-based trigger in SQL Server?


回答1:


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)




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/5573002/sql-2008-r2-time-based-triggers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!