当前位置: 代码迷 >> Sql Server >> 查询又更新有关问题。应该不难,但不知如何做
  详细解决方案

查询又更新有关问题。应该不难,但不知如何做

热度:10   发布时间:2016-04-25 01:12:47.0
查询又更新问题。应该不难,但不知怎么做。
从account表查询20000条记录并更新这20000条记记录的result字段改为1。
还有可能有20万的记录同时这样操作,效率尽量高些。






------解决方案--------------------
select top 20000 * from account
UPDATE TOP (20000) account set result=1
------解决方案--------------------
select top 20000 这里把除result之外的列列出来,1 as result from accoun
------解决方案--------------------
SQL code
--更新前select *  from account  where id between 1 and 20000--更新update account set result=1 where id between 1 and 20000--更新后select * from account where result=1
  相关解决方案