如何比较sql server中的不同值 [英] How to compare different values in sql server
本文介绍了如何比较sql server中的不同值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我必须检查两个值 X 和 Y 是否不同.如果两者都为空,则必须将它们视为相等.
I must to check if two values, X and Y are different. If both are null, they must be considered as equal.
我发现的独特方式是:
select 1 as valueExists
where (@X is null and @Y is not null)
or (@Y is null and @X is not null)
or (@X <> @Y)
有没有聪明的方法来写这个表达式?谢谢!
Is there a smart way to write this expression? Thanks!
推荐答案
您可以使用 ISNULL
WHERE ISNULL(@X,'') <> ISNULL(@Y,'')
这篇关于如何比较sql server中的不同值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文