• Curious if the following would work in this situation with proper indexing of the target table.

    WITH TableA_CTE AS(

    SELECT TOP (@TOP_HANDLED_ROWS)

    TableAID,

    TableAStatusTypeID,

    LastUpdateTime

    FROM

    dbo.TableA

    WHERE

    WaitingRoomCreationTime < dateadd(minute, -@wrExpirationMinutes, @curUtcDate)

    AND TableAStatusTypeID IN (1,2,3,4) -- CreatePending/Creating/Created/CreatedReportFailed

    ORDER BY

    WaitingRoomCreationTime asc

    )

    UPDATE TableA_CTE SET

    TableAStatusTypeID= 9,

    LastUpdateTime = @curUtcDate;

    go