• Robert-378556 (12/3/2012)


    SQL Kiwi (12/3/2012)


    Jaroslav Pfauser (12/3/2012)


    (0 row(s) affected)

    SQL2008 (64-bit) SP2

    It seems you wrote a test script that did not cover the full range of possibilities. Include CHAR(198) and CHAR(230) in your test.

    (2 row(s) affected)

    Doesn't the test sql provided in answer already do that?

    On my server it returns 0 rows, so it appears like some other things affect this. Maybe default collation. Probably.

    Yes, the default collation. The test sql in the answer works where the default collation is one of the Latin1_General set, but for some other collations it doesn't. I should have specified a default collation for the context of the code as part of the answer. What 8-bit character char(I) delivers depends on the default collation for the context in which char is called, so that whether ascii(char(I)) = I (I a non-negative integer less than 256) depends on what I is and what the default collation is. Personally I think that's unfortunate, but that's how char operates.

    Tom