delete from table where datediff(day,indate,getdate())>0
delete from info_table where day(convert(smalldatetime,Date_format,120))<>day(convert(smalldatetime,getdate(),120))
delete info_table where datediff(dd,indate,getdate())!=0
高效的写法: delete from 表名 where indate<convert(varchar(10),getdate(),120) and indate>=convert(varchar(10),getdate()+1,120)要避免对时间字段做任何运算,那样可能导致建在该时间字段上的索引不起作用
delete info_table where datediff(dd,indate,getdate())<>0
day(convert(smalldatetime,Date_format,120))<>day(convert(smalldatetime,getdate(),120))
delete from 表名 where indate<convert(varchar(10),getdate(),120)
and indate>=convert(varchar(10),getdate()+1,120)要避免对时间字段做任何运算,那样可能导致建在该时间字段上的索引不起作用
想法不错,但时间格式不是120的话,可以就不是你想要的操作了