一定时间后如何执行sql查询 [英] how to execute a sql query after a certain time

查看:95
本文介绍了一定时间后如何执行sql查询的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好

我正在做一个应用程序,大约30分钟后,我必须从数据库中删除一个perticuler用户数据.
谁能告诉我该怎么做..

Hi all

i am doing one application where after 30 min(approx.) i have to delete a perticuler users data from the DB.
can any one tell me how to do that..

推荐答案


这是一些有用的链接,

MSDN:SQL Server作业调度 [ SQL代理:作业调度程序框架 [
Hi
Here are some useful links,

MSDN : SQL Server Job scheduling[^]

SQL Agent: A Job Scheduler Framework[^]

Or you can also create windows task scheduler and execute your query through windows application(exe) execution with given interval of time.

Hope this all information helps you to solve your issue,

Thanks
-Amit Gajjar.


如果您需要实际删除用户,则必须在计划的时间运行控制台应用程序.

我认为您应该对此进行重新思考,并稍作调整.您可以轻松得多.在用户表上添加一列(DateTime).将该日期设置为DateTime.Now.加载该用户时,请检查该时间是否少于30分钟.如果不是,则将其视为已删除.
If you need to actually delete the user, you will have to run a Console App at scheduled time or something.

I think you should rethink this and turn it around a bit. You could do this a lot easier. Add a column (DateTime) on your user table. Set that date to DateTime.Now. When you load that user, check if that time is less then 30 minutes ago. If it''s not, treat it as deleted.


设置Sql作业
步骤如下...
set Sql job
steps are as below...
MsSQL -> ObjExplorer -> SqlServerAgent ->New (if not accessible then start sql agent service)-> Job -> 
 
in this new window,
general tab -> Name=test
               Desc=trial...
               check 'Enable' option
Steps tab -> New -> StepName=one      type=trans-SqlScr(TSQL)
                    Database=Your_DB
                    cmd= Copy paste all your delete queries here.
                    
                    Advance tab -> On success action=Quit the job
 
Schedule tab -> New -> Name=From Morning daily
                       Schedule type= Reccuring
                       check 'Enable' option
                       Daily Frequency => check 'Occure once' at = 10 AM
                                          check 'No End date'
OK



有关更多详细信息,请参见链接



for more details refer link

http://www.codeproject.com/Answers/436811/With-out-vs-2010-front-end-i-want-to-delete-multip#answer2


祝您编码愉快!
:)


Happy Coding!
:)


这篇关于一定时间后如何执行sql查询的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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