sybase で大規模な更新を行う必要があります。
Table1 には、列 a、b、c、e、f があり、約 900 万のレコードがあります。Table2 には、列 a、e、f、約 500000 レコードがあります。
syslog がいっぱいのため、以下の更新 SQL が失敗しました
update table1
set e = table2.e, f = table2.f
from table1, table2
where table1.a = table2.a
インターネットで調査を行った後、次の 2 つの手順は同じエラーのために失敗しましたが、5000 レコードは正常に更新されました。
何か案は。ありがとうございました!
SET ROWCOUNT 5000
WHILE (1=1)
BEGIN
update table1
set e = table2.e, f = table2.f
from table1, table2
where table1.a = table2.a
IF @@ROWCOUNT != 5000
BREAK
END
SET ROWCOUNT 0
declare @errorStatus int, @rowsProcessed int
set rowcount 5000
select @rowsProcessed = 1
while (@rowsProcessed != 0)
begin
begin tran
update table1
set e = table2.e, f = table2.f
from table1, table2
where table1.a = table2.a
select @rowsProcessed = @@rowcount, @errorStatus = @@error
if (@errorStatus != 0)
begin
--raiserror ....
rollback tran
--return -1
end
commit tran
end
set rowcount 0