Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the value of NULL in SQL Server?

I know NULL is not zero... nor it is empty string. But then what is the value of NULL... which the system keeps, to identify it?

like image 833
Relativity Avatar asked Jun 05 '10 16:06

Relativity


People also ask

Is NULL equal to 0 in SQL?

In SQL Server, NULL value indicates an unavailable or unassigned value. The value NULL does not equal zero (0), nor does it equal a space (' '). Because the NULL value cannot be equal or unequal to any value, you cannot perform any comparison on this value by using operators such as '=' or '<>'.

Is 1 NULL in SQL?

Because the result of any arithmetic comparison with NULL is also NULL , you cannot obtain any meaningful results from such comparisons. In MySQL, 0 or NULL means false and anything else means true. The default truth value from a boolean operation is 1 .

How do I show NULL values in SQL?

You must use the IS NULL or IS NOT NULL operators to check for a NULL value. Consider the following CUSTOMERS table having the records as shown below.


2 Answers

NULL is a special element of the SQL language that is neither equal to or unequal to any value in any data type.

As you said, NULL is not zero, an empty string, or false. I.e. false = NULL returns UNKNOWN.

Some people say NULL is not a value, it's a state. The state of having no value. Sort of like a Zen Koan. :-)

I don't know specifically how MS SQL Server stores it internally, but it doesn't matter, as long as they implement it according to the SQL standard.

like image 198
Bill Karwin Avatar answered Sep 28 '22 11:09

Bill Karwin


I believe that for each column that allow nulls, the rows have a null bitmap. If the row in the specified column is null the bit in the bitmap is 1 otherwise is 0.

like image 26
Adrian Fâciu Avatar answered Sep 28 '22 11:09

Adrian Fâciu