在指定时间删除行/数据 [英] Delete rows/data on specified time

查看:79
本文介绍了在指定时间删除行/数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图根据当前日期创建一个删除行的查询。有效。但现在,我希望是否有可能在指定时间内删除数据。因此用户可以选择他/她希望何时删除数据。例如凌晨4点。我如何使用当前的代码执行此操作。请帮忙。



 mysql_query(  DELETE FROM`sec_codes` WHERE DATE(date)< CURDATE()); 

解决方案

HI



尝试SQL Server工作



创建Transact-SQL作业步骤 [ ^ ]



使用SQL Server Management Studio创建数据库备份作业 [< a href =http://blogs.msdn.com/b/sqlagent/archive/2010/10/12/create-a-database-backup-job-using-sql-server-management-studio.aspxtarget = _blanktitle =新窗口> ^ ]



问候,

GVPrabu


铜rTime()也是作为CurDate()的Smae函数;因此,如果CurDate()正在工作,那么CurTime()也应该工作。

试一试。


您好,通过以下代码,您可以根据需要更改条件。您可以将参数传递给您想要的日期时间删除记录。我已经注释删除查询的代码首先检查选择然后如果确定然后执行删除语句



声明@ date1 varchar(16)

--set @ date1 =''2013-02-24 01:10''

set @ date1 = convert(varchar(10),getdate(),120)+''01:35 :00''

选择*,转换(datetime,rct,111)

- ,@ date1

from photo_test where convert(datetime ,rct,111)>转换(datetime,@ date1,111)



- 从photo_test中删除convert(datetime,rct,111)>转换(日期时间,@ date1,111)

I was trying to make a query that would delete the rows according to the current date. it worked. but now, I wished if its possible to delete the data on a specified time. so the user can select when he/she wishes to delete the data. for example 4am. how do i do that with the current code I have. Please help.

mysql_query("DELETE FROM `sec_codes` WHERE DATE(date) < CURDATE()");

解决方案

HI

Try SQL Server Jobs

Create a Transact-SQL Job Step[^]

Create a database backup job using SQL Server Management Studio[^]

Regards,
GVPrabu


CurTime() is also the Smae function as CurDate(); So if CurDate() is Working then CurTime() should also work.
Try it.


Hi,Go through the following code you can change the condition as you want.You can pass the parameter for date time on which you want to delete the record. I have commented code for delete query first check with select then if it is ok then execute delete statement

declare @date1 varchar(16)
--set @date1=''2013-02-24 01:10''
set @date1=convert(varchar(10),getdate(),120)+'' 01:35:00''
select *,convert(datetime,rct,111)
--,@date1
from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111)

--Delete from photo_test where convert(datetime,rct,111) > convert(datetime,@date1,111)


这篇关于在指定时间删除行/数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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