De eneste gyldige sammenligningsoperationer med NULL
værdier er IS NULL
eller IS NOT NULL
, andre returnerer altid falsk (faktisk - Ukendt, se @Damien_The_Unbelievers kommentar)
Så prøv følgende
CREATE TYPE [dbo].[BitType] AS TABLE(
[B] [tinyint] NOT NULL
)
GO
declare @theBitTypeTable BitType
insert @theBitTypeTable
VALUES(0), (2 /* instead of NULL*/)
SELECT something FROM theTable WHERE IsNull(cast(item as tinyint), 2) IN (select B from @theBitTypeTable)