select top 1000 id=identity(int,1,1),1 col into # from sysobjects,syscolumns
set statistics time on
update # set col=col+1 where id<=1000
set statistics time off
drop table #SQL Server 执行时间:
   CPU 时间 = 0 毫秒,占用时间 = 4 毫秒。(1000 行受影响)

解决方案 »

  1.   

    select top 1000 id=identity(int,1,1),1 col into # from sysobjects,syscolumns
    set statistics time on
    update # set col=col+1
    set statistics time off
    drop table #/*
    SQL Server 执行时间:
       CPU 时间 = 15 毫秒,占用时间 = 3 毫秒。(1000 行受影响)
    */
      

  2.   


    --看看下面的两个时间差,就知道你用了多少时间。
    select getdate()
    update tb set col=1
    select getdate()
      

  3.   

    看来各位都是高手!
    但是,他的意思好像是,限定300毫秒之内,更新1000条记录。
    有些update是很费时间的,如果超过300毫秒,该怎么办?
      

  4.   

    添加合理索引,能快速定位这1000条数据。
    如果只考虑Update的效率,可以考虑根据where 出现的列上建立簇索引,
    保证数据存在相邻的数据页上。
    300毫秒能否更新完,跟硬件、锁、系统压力等状况,有很大关系。