• looks like no problem...you simply need to add that additional check to your update...

    something like this looks correct to me, base don what you posted so far:

    this would be the query that should show you everything in the current matching criteria i think you've provided:

    SELECT *

    FROM AGS_Hands_InProcess

    WHERE Win is NULL -- protection.

    AND ts_started < DATEADD(hh, -1, GETDATE())

    and cuserid IN ( select

    cuserid

    from UserBalanceAdjustments

    where ReasonForAdjustment like 'ADJ AGS%'

    and AGS_Hands_InProcess .transactiontime>dateadd(ww,-1,getdate()) -- for efficiency, limit the time window, e.g. a week

    )

    and this would be the all inclusive update:

    UPDATE AGS_Hands_InProcess SET

    Win= 5, -- the value from the matching Adjustement

    ts= getdate() -- the timestamp of last action on this hand

    WHERE Win is NULL -- protection.

    AND ts_started < DATEADD(hh, -1, GETDATE())

    and cuserid IN ( select

    cuserid

    from UserBalanceAdjustments

    where ReasonForAdjustment like 'ADJ AGS%'

    and AGS_Hands_InProcess.transactiontime>dateadd(ww,-1,getdate()) -- for efficiency, limit the time window, e.g. a week

    )

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!