Hi I learned sql server's BIT
has true, false, and unknown. For example, the comparison 1 > NULL
yields unknown
.
I know I can check it indirectly: if x is null or y is null
, then the comparison x > y
must be unknown
.
Is there a way to access unknown
directly? For example
select *
into #t
from (
SELECT 1 as [x], 1 as [y] UNION ALL
SELECT 1 as [x], 2 as [y] UNION ALL
SELECT 1 as [x], NULL as [y]
) as a
SELECT *
from #t
--x y
--1 1
--1 2
--1 NULL
select *
,/* ???? */ as [is x > y]
from #t
--want to have:
--x y is x > y
--1 1 0
--1 2 0
--1 NULL unknown