Is there an ms sql parameter that allows us to assign a value! = Null?

in MS SQL I came up with the following query:

select Wubba, Dubba
from Dub as dub
where Dubba != 10

When Dubbanull, the selection returns null strings. Since I was looking for an error, I was wondering if there is a parameter in MS SQL that will allow this query to return values.

+4
source share
3 answers

There is no setting that provides the behavior you are looking for. You can try below

Dubba != 10 or dubba is null

Usage ISNULL(somecol,val)Not Sargable

there is a setting called SET ANSI_NULLS , but this will not work when comparing

SET ANSI_NULLS , SELECT, WHERE column_name = NULL, , _

SET ANSI_NULLS , SELECT, WHERE column_name = NULL, _

SET ANSI_NULLS is ON Null < > Null
SET ANSI_NULLS is OFF Null = Null

nulls, NULL, nulls -

-:


+3

, , :

select Wubba, Dubba
from Dub as dub
where ISNULL(Dubba, 0) != 10
+2
select Wubba, Dubba
from Dub as dub
where Dubba != 10 Or Dubba Is Null

0

Source: https://habr.com/ru/post/1658227/


All Articles