How to compare different values in sql server

前端 未结 4 1206
日久生厌
日久生厌 2021-01-07 08:10

I must to check if two values, X and Y are different. If both are null, they must be considered as equal.

The unique way I found is:

select 1 as valu         


        
4条回答
  •  猫巷女王i
    2021-01-07 08:29

    You could try using NULLIF like this:

    WHERE NULLIF(@X,@Y) IS NOT NULL OR NULLIF(@Y,@X) IS NOT NULL
    

提交回复
热议问题