--UPDATE dbo.Notice WITH(ROWLOCK) SET IsNoAOG=0,IsSection35=0 WHERE IsNoAOG IS NULL AND IsSection35 IS NULL
DECLARE @Rows INT = 50000
WHILE 1=1 BEGIN UPDATE TOP (@Rows) dbo.Notice WITH (ROWLOCK) SET IsNoAOG=0,IsSection35=0 FROM dbo.Notice n WHERE IsNoAOG IS NULL AND IsSection35 IS NULL IF @@RowCount < @Rows BREAK END
--==================================
DECLARE @Rows INT = 50000
WHILE 1=1 BEGIN ;WITH Part1 AS ( SELECT DISTINCT NotIntNo FROM dbo.Charge c WITH (NOLOCK) WHERE ChgNoAOG = 'Y' AND ChargeStatus < 900 ) UPDATE TOP (@Rows) dbo.Notice WITH (ROWLOCK) SET IsNoAOG = 1 FROM dbo.Notice n WHERE ISNULL(IsNoAOG, 0) = 0 AND NoticeStatus < 900 AND EXISTS ( SELECT 1 FROM Part1 p WITH (NOLOCK) WHERE p.NotIntNo = n.NotIntNo ) IF @@RowCount < @Rows BREAK END