HadoopAddict HadoopAddict - 4 months ago 11
SQL Question

How to compare nulls without using IsNull in SQL Server

How do I write the below statement without using

IsNULL
?

Case
When (IsNull(Email_Ind, '') != 'N'
then 'e'
else 'n'
end


Does this get the right results ?

Case
When Email_Ind != 'N' and Email_Ind is not null
then 'e'
else 'n'
end

Answer

Your case statement looks fine. It's just a matter of preference on how to write it. To me, this is more easily understandable but that's not the case for all i'm sure.

Case When Email_Ind != 'N' or Email_Ind is null  then 'e' else 'n' end
Comments