大家有什么高效率的实现办法吗?
我只知道
select top 500 from table order by id ase
update table set isuse = 1 where id < (select max(id) from (select top 500 from table order by id ase))
思路是这样的,大家给点意见

解决方案 »

  1.   

    搜索和更新是SELECT 和 UPDATE两条语句的事,不能混为一谈
      

  2.   

    select top 500 * from [table] order by id asc
    update [table] set isuse = 1 
    where id in(select top 500 id from [table] order by id asc)
      

  3.   

    你的思路可以的啊!只是要改一下小地方select top 500 * from [table] order by id 
    update [table] set isuse = 1 
    where id < (select max(id) from (select top 500 id from [table] order by id )t)
      

  4.   

    更新语句条件是小于等于
    update [table] set isuse = 1 
    where id <=(select max(id) from (select top 500 id from [table] order by id )t)
      

  5.   

    谢谢
    lsqkeke(可可)
    有没有考虑过两种方法哪个效率会高一些呢?
      

  6.   

    有没有考虑过两种方法哪个效率会高一些呢?
    ----------------------
    你的方法高效一点!
    因为:SQL在执行计划中:
    select max(id) from (select top 500 id from [table] order by id )t
    该语句总共执行一次! 作大小判断时,也是一次!而我的写法呢,在id 是否包含在后面的集合时,花了较多的时间