i an new in vb.net sql and what i am asking may be silly question. I have a table in sql server 2005 and a column name activated. this column contain NULL, true or false.
I want to select only NULL or false values. How can i do this?
i an new in vb.net sql and what i am asking may be silly question. I have a table in sql server 2005 and a column name activated. this column contain NULL, true or false.
I want to select only NULL or false values. How can i do this?
8条答案
按热度按时间7uzetpgm1#
The selection should be done on the SQL Server's side. Your query should look like this:
The above assumes that the column
activated
is of an integral or aBIT
data type.Note: it may be tempting to use a seemingly equivalent
WHERE activated <> 1
condition. This would be incorrect, though, because comparisons ofNULL
values to anything result in aNULL
, so the rows withactivated = NULL
would be excluded.m1m5dgzv2#
You should be able to do a coalesce on the field to get it to false if it is null. A coalesce statement checks to see if the first parameter is null, if it is it returns the value in the second parameter. There would be two solutions:
--OR--
cgh8pdjw3#
With SQL's 3-valued logic, comparisons for NULL need to be done using the
IS NULL
operator... the check for false can be done with=
:1dkrff034#
Sometimes you have to see it to believe...
zed5wv105#
de90aj5v6#
For checking NULL you have to use the keyword
"IS NULL"
and for false=0
like belowvwoqyblh7#
The SQL way is to use IS TRUE or similar:
798qvoo88#
@girgen
Hi, in Sql server this query is not true.
This query is for MySql Query not in Sql server. in sql server you can use IS NOT NULL.