ist ein möglicher Ansatz ohne set rowcount
-- prepare test data
use tempdb
drop table dbo.t;
create table dbo.t (a int identity, b int)
go
insert into dbo.t (b)
values (1), (2), (3), (4), (5), (6), (7), (8), (9), (10), (11);
go
-- assume we do 3 records per time, put 10000 here if you wnat 10K records
-- also the update is just to update column [b] to [b] * 2, here is the code
declare @N int = 3; -- do a batch of @N records
declare @i int = 0, @max_loop int;
select @max_loop = count(*)/@N from dbo.t
-- the first batch may include records <= @N-1 and the last batch may include records <= @N
while (@i <= @max_loop)
begin
; with c as (
select rnk=ROW_NUMBER() over (order by a)/@N, a, b from dbo.t
)
update c set b = b*2 -- doule b
where rnk = @i;
set @i = @i + 1;
end
go
-- check the result
select * from dbo.t
Welches Skript verwenden Sie im Moment? – mfredy
Verwenden Sie ROWCOUNT NICHT, um zu steuern, wie Zeilen mit einer UPDATE-Anweisung aktualisiert werden. Die Verwendung hierfür ist veraltet und wird in Zukunft nicht mehr funktionieren. https://msdn.microsoft.com/en-us/library/ms188774.aspx –
Ist Ihre Absicht, jede Zeile 10.000 auf einmal oder nur die oberen 10.000 Zeilen zu aktualisieren? – ZLK