Update records separated by group

  • I'm a little confused to your request. What do you mean 'by group'?


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • Assuming by "group" you're referring to the AuditTeamID, I think this gets you what you need.

    ;with qry as

    (

    Select 5 AS InternalAuditTeamEmployeeID, 1 as InternalAuditTeamID

    UNION ALL

    Select 11, 2

    UNION ALL

    Select 14, 3

    )

    update a

    set flag = 1

    from tblInternalAuditTeamEmployee a

    inner join qry b

    on a.InternalAuditTeamID = b.InternalAuditTeamID

    and a.InternalAuditTeamEmployeeID <= b.InternalAuditTeamEmployeeID

    Executive Junior Cowboy Developer, Esq.[/url]

  • Sorry about leaving the specifics of the group out. Before submitting, I read my post and it made sense to me - of course. Sorry I missed the details. JeeTee's solution is spot on to what I was trying to achieve. I've never used anything on an inner join other than the = operator and didn't even realize I could (sometimes I completely miss the simple things :-)). Thank you for the solution, and for helping me learn something new today!

    Thanks,

    Kevin

Viewing 3 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply