Are there any features within Microsoft SQL Server TSQL that could shorten this CASE WHEN statement?
CASE
WHEN some_column IS NULL
THEN 0
ELSE 1
END
Are there any features within Microsoft SQL Server TSQL that could shorten this CASE WHEN statement?
CASE
WHEN some_column IS NULL
THEN 0
ELSE 1
END
For SQL Server 2012 and later you can use IIF() statement.
SELECT IIF(some_column IS NULL , 0 , 1)
You could use what SQL Server documentation calls the "simple" case expression, instead of the "search" case expression that the syntax in the question uses.
case some_column when null then 0 else 1 end
Not a large difference, but it is shorter.