怎么用循环删除数据,通过时间
delete  from tableA  
where datediff(mm,EndDateTime,getdate())>3

解决方案 »

  1.   

    你都写出来了 加个while子句来判断就行了 
      

  2.   

    set rowcount 1000
    go
    while(1)
    begin
       
       delete  from tableA  
       where datediff(mm,EndDateTime,getdate())>3
       WAITFOR DELAY 10
    end
      

  3.   

    Delete top (1) from T1 where datediff(mm,EndDateTime,getdate())>3建议不要用set rowcount 1000
      

  4.   

    搞什么飞机,都不对
    我要用WHILE 
      

  5.   

    http://topic.csdn.net/u/20091011/19/46befa25-1b88-4da9-beae-e5aeb7564412.html参考
      

  6.   


    while exists (select 1 from tableA where datediff(mm,EndDateTime,getdate())>3)
    begin 
    delete top (10000) from  tableA where datediff(mm,EndDateTime,getdate())>3)
    end