Why does NULL = NULL evaluate to false in SQL server

前端 未结 19 2003
一向
一向 2020-11-22 05:02

In SQL server if you have nullParam=NULL in a where clause, it always evaluates to false. This is counterintuitive and has caused me many errors. I do understa

19条回答
  •  野的像风
    2020-11-22 05:37

    If you are looking for an expression returning true for two NULLs you can use:

    SELECT 1 
    WHERE EXISTS (
        SELECT NULL
        INTERSECT
        SELECT NULL
    )
    

    It is helpful if you want to replicate data from one table to another.

提交回复
热议问题