This might be a very basic question but I just came over it while writing a query.
Why can't SQL Server convert a check for NULL
to BIT
? I was thinking about something like this:
DECLARE @someVariable INT = NULL;
-- Do something
SELECT CONVERT(BIT, (@someVariable IS NULL))
The expected outcome would then be either 1
or 0
.
Use case
:
SELECT CONVERT(BIT, (CASE WHEN @someVariable IS NULL THEN 1 ELSE 0 END))