Hallo Ich lernte SQL Server BIT
hat wahr, falsch und unbekannt. Zum Beispiel ergibt der Vergleich 1 > NULL
unknown
.wie auf UNBEKANNT in Sql-Server boolean zugreifen?
Ich weiß, ich kann es indirekt überprüfen: wenn x is null or y is null
, dann muss der Vergleich x > y
unknown
sein.
Gibt es eine Möglichkeit, direkt auf unknown
zuzugreifen? Zum Beispiel
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
Ich denke, "unbekannt" wird als "NULL" dargestellt. –