读书人

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

发布时间: 2012-11-03 10:57:44 作者: rapoo

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

读书人网 >SQL Server

热点推荐