最佳答案
UPDATE dbo.TestStudents
SET LASTNAME =
( CASE
WHEN (LASTNAME = 'AAA') THEN 'BBB'
WHEN (LASTNAME = 'CCC') THEN 'DDD'
WHEN (LASTNAME = 'EEE') THEN 'FFF'
ELSE (LASTNAME)
END )
语句可以正常工作,但 else 条件会扫描表中的每条记录。有什么办法可以让这些未受影响的行保持原样吗?