日期:2014-05-17  浏览次数:20673 次

查询又更新问题。应该不难,但不知怎么做。
从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