简体   繁体   English

如何在 sql 服务器查询中同时实现 IsNull 和 Isempty

[英]How can I implement IsNull and Isempty together in sql server query

here I wanted to check if coming value is empty string or null then use value from Db column.Like I did for is null case.在这里,我想检查即将到来的值是空字符串还是 null 然后使用 Db 列中的值。就像我做的是 null 案例。 How can i check for empty string in this line of code.Please suggest我如何在这行代码中检查空字符串。请建议

II.[NAME] = isNull(IIMODEL.[Name], II.[NAME]), 
II.[NAME] = ISNULL(NULLIF(TRIM(IIMODEL.[NAME]), ''), II.[NAME])

Why not just use explicit comparisons?为什么不直接使用显式比较?

(II.[NAME] = IIMODEL.[Name] OR IIMODEL.[Name] IS NULL OR IIMODEL.[Name] = '')

I think the logic is much simpler to follow.我认为逻辑要简单得多。

case when isnull([column], '') <> '' then [column] else [other] end

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM