我正在尝试将2更改为Complete,2是varchar值 但每次进入else子句
CASE [consent_complete]
WHEN '2' THEN 'Complete'
ELSE 'IN Complete'
END AS 'Complete?'
答案 0 :(得分:3)
我怀疑你的数据最后有空格和/或\0
字符:
SELECT ...
CASE
WHEN LEFT(LTRIM(RTRIM([consent_complete])),1) = '2' THEN 'Complete'
ELSE 'Incomplete'
END AS [Complete?]
FROM ...
此外,您应该清理数据TRIM
空格和REPLACE
\0
字符。