• malleswarareddy_m (4/5/2010)


    john.arnott (4/5/2010)


    malleswarareddy_m (4/4/2010)


    Good QOD.This Question gives good information about bit datatypes.

    when we use space or all zero it bit will convert it into zero.If we give numeric(numbers) it will convert it into one.

    . . . .

    This is true for other numeric datatypes as well. Spaces or empty strings are implicitly converted to zero

    DECLARE @MyNum int

    SET @MyNum = ' '

    -- attempt arithmetic operation

    Select @myNum * 4

    -- result is 0, not an error.

    I think it will throw error when converting it to string datatype except(TRUE/False)

    Sorry?? What will cause an error?

    Your statement looks to be reversed of what you may have meant -- aren't we talking about converting from strings to numerics? My example of implicit conversion from a string to an int does not cause an error, nor would an empty string, the point being that it's not just conversions to the bit type where empty or blank strings result in zero.

    I didn't find a BOL or MSDN article on this specific behavior, but from what I did find, it seems clear that the SQL engine sets the target to zero, then adds the numeric evaluation of the string, ignoring spaces. With nothing else to evaluate, the result remains zero.

    You say you "think it will throw error". Did you try it?