SQL Server - boolean literal?

前端 未结 13 866
深忆病人
深忆病人 2020-12-04 22:56

How to write literal boolean value in SQL Server? See sample use:

select * from SomeTable where PSEUDO_TRUE

another sample:



        
13条回答
  •  北海茫月
    2020-12-04 23:34

    SQL Server doesn't have a boolean data type. As @Mikael has indicated, the closest approximation is the bit. But that is a numeric type, not a boolean type. In addition, it only supports 2 values - 0 or 1 (and one non-value, NULL).

    SQL (standard SQL, as well as T-SQL dialect) describes a Three valued logic. The boolean type for SQL should support 3 values - TRUE, FALSE and UNKNOWN (and also, the non-value NULL). So bit isn't actually a good match here.

    Given that SQL Server has no support for the data type, we should not expect to be able to write literals of that "type".

提交回复
热议问题