我选择出来一堆数据但是我只是想更新第一条记录就可以了,应该怎么写代码?

解决方案 »

  1.   

    update top 1 
    set 字段1=··· 
    where 条件···符合条件的有很多
    但是我只想更该第一个~~上面代码无法运行
      

  2.   


    update tb
    set name='...'
    from tb
    where id=(select top 1 id from tb order by id asc )参考吧
      

  3.   


    --如果没有特殊要求,更新随便哪一条都行的话,那就执行set rowcount 1
    update tb set name='...'
    where ......
    set rowcount 0--如果要根据某写字段排序,那就用update set name='...' from tb
    where id=(select top 1 id from tb where ... order by...)
      

  4.   

    如果一次更新两个表
    update tb,tb
    set ss=````
    where ``````
    怎么无法执行