Is it possible to use case statement within an update query? I need to do something like this: If person name starts with ‘S’ then append ‘1’, else append ‘2’.
I tried this in sql server and it didn’t work
UPDATE PERSON CASE WHEN NAME LIKE 'S%' THEN SET NAME = NAME + '1' ELSE SET NAME = NAME + '2' END
Just to add a slightly different variant that I tend to prefer (down to personal preference).
I like this because it saves repeating the “Name +” bit for each condition – in this case it’s nothing major, but in other scenarios with more conditions it can be overly repetitive