存储过程在特定时间运行 [英] stored procedures to run at a particular time
问题描述
亲爱的所有人,
任何人都可以指导我一些解决方案。现在我在表中添加som信息,比方说Sampletb。我在Sampletb中有一些像Time,Status这样的列。
我的要求是如果我在Sampletb中输入任何记录,并在时间栏中输入日期(例如:27-dec-2013 23:00)。
在此特定日期和时间,特定记录的状态应更改为1 ....
我尝试创建触发器,但触发器无法在特定时间触发..只有当表中的任何记录更改或插入时才会运行...
研究我发现SQL Jobs是更好的选择..
我的想法是什么我会创建一个存储过程来更新状态并希望sqljob到在我提到的日期和时间运行程序....
请帮帮我...
Dear All,
Can anyone please guide me with some solution. Right now I am adding som infomation in a table, lets say as Sampletb. I have some column like Time,Status in Sampletb.
My requirement is if I enter any record in the Sampletb with a date (for ex:27-dec-2013 23:00) in the time column.
On this particular date and time,status of the particular record should be changed to 1....
I tried creating triggers but triggers cannot fire at a particular time..they run only when any record in the table changes or inserted...
After long research on this I found SQL Jobs are the better option for this..
what my thought is I will create a stored procedure to update the status and wants the sqljob to run the procedure at the date and time i mentioned....
Please help me with this...
推荐答案
我的想法是什么我将创建一个存储过程来更新状态并希望sqljob运行以下过程:我提到的日期和时间......
what my thought is I will create a stored procedure to update the status and wants the sqljob to run the procedure at the date and time i mentioned....
是的。
您可能需要在将行插入Sampletb表时动态创建SQL作业。
所以,请参考使用T-SQL创建SQL Server作业的简单方法 [ ^ ]。
正如您在问题中提到的,您可以安排作业在任何特定时间运行存储过程。
请参阅显示相同的链接。
http://devwar.blogspot.in/2010/05/schedule-stored-procedure-to-run-in-sql.html [ ^ ]
http://www.sqlteam.com/article/scheduling-jobs-in-sql-server-express [ ^ ]
希望这会有所帮助...
As you mentioned in your question, you can schedule a job to run the Stored Procedure on any specific time.
Refer the link which shows the same.
http://devwar.blogspot.in/2010/05/schedule-stored-procedure-to-run-in-sql.html[^]
http://www.sqlteam.com/article/scheduling-jobs-in-sql-server-express[^]
Hope this helps...
创建SQL服务器作业 [ ^ ],创建计划 [ ^ ]然后将作业附加到日程表。 [ ^ ] - 是的,你正朝着正确的方向前进。
祝你好运
Espen Harlinn
Create an SQL server job[^], create a schedule[^] and then attach the job to the schedule.[^] - so yes, you're heading in the right direction.
Best regards
Espen Harlinn
这篇关于存储过程在特定时间运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!