在特定时间后调用存储过程. [英] Calling Stored procedure after a specific amount of time.
本文介绍了在特定时间后调用存储过程.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
大家好!
我需要调用存储过程以在特定时间后从数据库中删除数据.怎么做?
我正在工作门户网站上.员工发布职位后,我希望在员工设置的特定天数后删除该职位.
Hi All!!
i need to call a stored procedure to delete data from database after a specific amount of time. How will it be done ?
i am working on a job portal. After an employee has posted job , i want the job to deleted after a specific no of days set by the employee.
推荐答案
可以通过使用Jobs,Jobsteps来实现和运行作业的计划.请参考如何在MSDN上创建文档:如何创建SQL Server代理作业(Transact-SQL) [ ^ ].
This can be achieved by using Jobs, Jobsteps and Schedules that run the Job. Please refer to the documentation on MSDN on How to: Create a SQL Server Agent Job (Transact-SQL)[^].
- 执行 sp_add_job [a] ^ ]创建工作.
- 执行 sp_add_jobstep [ ^ ]创建一个或多个作业步骤.
- 执行 ^ ]创建时间表.
- 执行 ^ ]至
- 执行 sp_add_jobserver [ ^ ]设置作业服务器.
- Execute sp_add_job [^]to create a job.
- Execute sp_add_jobstep[^] to create one or more job steps.
- Execute sp_add_schedule[^] to create a schedule.
- Execute sp_attach_schedule[^] to attach a schedule to the job.
- Execute sp_add_jobserver[^] to set the server for the job.
除员工指定的有效期外,还应存储条目创建的日期.然后,您可以使用 T-SQL [日期算术 [
Besides the validity period specified by the employee the date when the entry was created should also be stored. You can then use T-SQL[^] date arithmetic[^] from your stored procedure to find all records that are no longer valid.
Regards,
您可以创建一个" SQL Server作业"来按计划调用存储过程.
创建新工作.
http://msdn.microsoft.com/en-us/library/ms190268.aspx
安排您的工作.
http://msdn.microsoft.com/en-us/library/ms191439.aspx
You may create a "SQL Server Job" to call your Stored Procedure on schedule basis.
Create New Job.
http://msdn.microsoft.com/en-us/library/ms190268.aspx
Schedule your Job.
http://msdn.microsoft.com/en-us/library/ms191439.aspx
这篇关于在特定时间后调用存储过程.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文