深入SQLServer中ISNULL与NULLIF的使用详解

时间:2021-05-02

SQL Server里的 ISNULL 与 ASP 中的 IsNull不同,SQL Server 中有两个参数,语法:
ISNULL(check_expression, replacement_value)

•check_expression 与 replacement_value 数据类型必须一致
•如果 check_expression 为 NULL,则返回 replacement_value
•如果 check_expression 不为 NULL,则返回 check_expression

NULLIF 用于检查两个表达式,语法:
NULLIF(expression, expression)

•如果两个 expression 相等,则返回 NULL,该 NULL 为第一个 expression 的数据类型
•如果两个 expression 不相等,则返回第一个 expressio

声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。

相关文章