2

In t-sql, when you convert anything to datatype bit any nonzero value is converted to true. I am working on the premise of the column not being nullable. I would consider NULL to be a nonzero value, and surely if you convert the value null into datatype bit you would expect it to be 0 (AKA false).

This being said I wonder what exactly constitutes a nonzero value, as based on null being (as I consider it) a nonzero value it would be converted to the value 1 (true).

So my question really becomes is NULL a nonzero value, or is the value NULL (being the lack of a value) actually completely separate and does not count as a nonzero value or zero, and counts simply as NULL itself - and if this is the case then what would it be converted to if inserted into a non nullable column?

Many Thanks,

4

1 回答 1

0

在 TSQL 中,NULL 被认为是一个未知值,这就是为什么NULL <> 0 = NULL在转换为位时而不是 1。

于 2012-04-10T10:41:03.600 回答