UPDATE dbo.TestStudents
SET LASTNAME =
( CASE
WHEN (LASTNAME = \'AAA\') THEN \'BBB\'
WHEN (LASTNAME = \'CCC\') THEN \'DDD\'
WHEN (LASTNAME = \'EEE\') THEN \'F
If you don't want to repeat the list twice (as per @J W's answer), then put the updates in a table variable and use a JOIN
in the UPDATE
:
declare @ToDo table (FromName varchar(10), ToName varchar(10))
insert into @ToDo(FromName,ToName) values
('AAA','BBB'),
('CCC','DDD'),
('EEE','FFF')
update ts set LastName = ToName
from dbo.TestStudents ts
inner join
@ToDo t
on
ts.LastName = t.FromName