1、orderby 时间1 desc
2、delete from 表 where 时间2<getdate()

解决方案 »

  1.   

    楼上
    问题一:
    我的意思是
    order by  时间1-当前时间 =最小值 asc正确的该怎么写????问题二这句话应该写在哪?我如果应用它哪?
      

  2.   

    1、
    selct min(datediff(d,时间1,getdate())),时间1 from table  
    2、
    delete from table where 时间2=
    (select A.时间1 from (selct min(datediff(d,时间1,getdate())),时间1 from table ) A)
      

  3.   

    1、
    selct min(datediff(d,时间1,getdate())),时间1 from table  group by 时间1
    2、
    delete from table where 时间2=
    (select A.时间1 from (selct min(datediff(d,时间1,getdate())),时间1 from table group by 时间1) A)
      

  4.   

    我如何可以按照时间1与当天最近来排序????
    -----------------------------------------
    意思实际就是最靠近当前时间的时间吧,也就是最大的时间啦。那就直接
    Order By 时间1 Desc 
    就可以啊。
      

  5.   

    那第二个问题我查资料好象说得建个任务,在sqlserver中如何创建一个任务??????
      

  6.   

    如何在sqlserver中新建一个任务???