locked
How to update multiple rows with different id in sqlserver RRS feed

  • Question

  • User1839056048 posted

    Hi,

    i want to update multiple rows with different id

    following is the code


      update admin set [add]=1 where uname='jain' ,  set [edit] =1 where uname='baiju'
      my requirement is to update 2 values with different id

    following is error message

    Msg 102, Level 15, State 1, Line 2
    Incorrect syntax near ','.

    is it possible.

    Regards

    Baiju

    Thursday, February 18, 2016 3:16 PM

Answers

  • User77042963 posted
    update admin 
    set [add]=Case when uname='jain' then 1 else  [add] end  
    ,[edit] =Case when uname='baiju' then 1 else [edit] end 
    where uname='jain' Or uname='baiju'

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, February 18, 2016 3:36 PM

All replies