Update command with a case statement

Karthikanbarasan
Posted by Karthikanbarasan under Sql Server category on | Points: 40 | Views : 1513
Update table1
Set name = CASE
When name like 'A %' THEN (SUBSTRING(name, 5, 255) + ', D')
When name like 'B %' THEN (SUBSTRING(name, 4, 255) + ', E')
When name like 'C %' THEN (SUBSTRING(name, 3, 255) + ', F')
Else name
END;

Comments or Responses

Login to post response