case when null then 'xx' else 'yy' end 无效

Sql Server 中使用case when then 判断某字段是否为null,和判断是否为字符或数字时的写法不一样,而且语法能正常执行,

如果不注意数据内容,很容易搞错。




错误方法:

CASE columnName WHEN null THEN 0 ELSE columnName END



正确方法:

CASE WHEN columnName is null THEN 0 ELSE columnName END

原文地址:https://www.cnblogs.com/chengeng/p/5851856.html