SQL Server Performance

Why 0s are considered as NULLs...

Discussion in 'SQL Server 2005 General Developer Questions' started by ramkumar.mu, Aug 26, 2008.

  1. ramkumar.mu New Member

    declare @var bit
    select @var = 0
    if ISNULL (@Var,'') = '' print 'yes'
    else print 'no'
    the result is yes when i pass 0. But when i pass 1 for @var, it prints no.
    Can anyone explain Why does SQL Server considers 0 as NULLs?
  2. martins New Member

    SQL Server does not consider 0 = null, but converting '' to bit returns the same value as a 0 bit value (false). This should be clear if you change the above code to:declare @var bit
    @var = 0 if
    @var = '' print 'yes'else
    print 'no'
  3. Madhivanan Moderator

    More clearlydeclare
    @var bit set

Share This Page