Home Forums SQL Server 2008 T-SQL (SS2K8) 0 is equal to zero length string. Can someone explain how this can be? RE: 0 is equal to zero length string. Can someone explain how this can be?

  • I think that we would all agree that the following strings should all produce the same results when converted to an integer:

    ' 1'

    '01'

    So, it makes sense to me, that if we remove the right-most character, they should also produce the same results when converted.

    ' '

    '0'

    We also know that trailing spaces are ignored in many cases, so the following are essentially equivalent

    ''

    ' '

    So, by the law of transitivity, the result of converting all of these strings to integer should produce the same results.

    ''

    ' '

    '0'

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA