Why this statement return 0 instead of empty string? I am actually using a view which select statement containg hardcoded column return NULL. While I am trying to check if its a NULL, it actually returns 0.
SELECT ISNULL((SELECT NULL as Col), '')
Any suggestion or help would be appreciated...
<a href="http://i.stack.imgur.com/42Vex.png" rel="nofollow">snapshot</a>Answer1:
NULL does not have a clear type, but in a plain
SELECT NULL, it gets returned as type
int. When you have an expression involving an
int and a
int wins, the
char(N) value gets converted to
int, not the other way around. To make things more confusing,
'' happens to be convertible to
int without any problem, and the result of the conversion is
SELECT ISNULL((SELECT CAST(NULL AS char(1)) AS col), '') should return an empty string.