System.Data.SqlClient.SqlConnection x = new System.Data.SqlClient.SqlConnection("...");
System.Data.SqlClient.SqlCommand y =new System.Data.SqlClient.SqlCommand("update RevcordBiao set Time = getdate() from RevcordBiao a where time = (select max(time) from RevcordBiao where id = a.id) and id = 5",x);
y.ExecuteNonQuery();

解决方案 »

  1.   

    sql 语句:
    update RevcordBiao set [time]=getdate() where [time]=(select top 1 [time] from RevcordBiao where id=5 order by datediff(day,[time],getdate()))
      

  2.   

    如果有>今天的纪录,还应加上abs():
    update RevcordBiao set [time]=getdate() where [time]=(select top 1 [time] from RevcordBiao where id=5 order by abs(datediff(day,[time],getdate())))
      

  3.   

    playyuer(双规干部) ( ) 兄弟
    你的SQL语句我调试怎么老是有问题啊,你试没试啊
    ??????????
    ???????
      

  4.   

    可能有今天的记录啊???
    ??????哪就把day 该成second,参见datediff()联机帮助
      

  5.   

    update RevcordBiao 
    set Time = getdate() 
    from RevcordBiao a 
    where time = (select max(time) 
                    from RevcordBiao 
                   where id = a.id) 
          and id = 5