I'm curious as to why SQL server interprets a "zero" (0) as a blank in SQL Server. Understandably, if you have an int column, it should not be blank. I'm not referring to nulls...I understand how a null would be handled. But if you have a physical value of zero in an int column, it's strange to me that when testing with a case expression or through the where clause, that SQL Server would interpret a zero as blank. Here's an example that I set up:
declare @status table (intvalue int)
insert into @status (intvalue)
values
(0)
,('')
,(null)
SELECT intvalue,
case when intvalue='' then 'I''m Blank' end,
case when intvalue=0 then 'I''m Zero' end,
case when intvalue is null then 'I''m Null' end
FROM @status
(3 row(s) affected)
intvalue
----------- --------- -------- --------
0 I'm Blank I'm Zero NULL
0 I'm Blank I'm Zero NULL
NULL NULL NULL I'm Null
(3 row(s) affected)
Is this an option setting or is there some other explanation? Thanks!