T-SQL: Using a CASE in an UPDATE statement to update certain columns depending on a condition

后端 未结 6 833
再見小時候
再見小時候 2020-12-02 12:36

I am wondering if this is possible at all. I want to update column x if a condition is true, otherwise column y would be updated

UPDATE table SET
     (CASE          


        
6条回答
  •  佛祖请我去吃肉
    2020-12-02 13:17

    I want to change or update my ContactNo to 8018070999 where there is 8018070777 using Case statement

    update [Contacts] set contactNo=(case 
    when contactNo=8018070777 then 8018070999
    else
    contactNo
    end)
    

提交回复
热议问题