LIKE operation with non-english characters

  • Can anyone tell me why the following returns true? I can't help but wonder if it's a server-specific COLLATION setting or something like that, but I'm not sure:

    DECLARE @c VARCHAR(10)

    ,@i VARCHAR(10)

    SET @i=192

    SET @c=CHAR(@i)

    SELECT

    @c

    ,CASE WHEN @c LIKE '[A-Fa-f]' THEN 'true' ELSE 'false' END AS TestResult

  • yes.

    The probability of survival is inversely proportional to the angle of arrival.

  • sturner - Uh....yes you can explain it (but chose not to) or yes it is a collation setting (but you don't want to ellaborate).

  • Never mind, found the info I needed here:

    http://www.databasejournal.com/features/mssql/article.php/3302341/SQL-Server-and-Collation.htm

    So changing the code above to this, fixed it:

    DECLARE @c VARCHAR(10)

    ,@i VARCHAR(10)

    SET @i=192

    SET @c=CHAR(@i)

    SELECT

    @c

    ,CASE WHEN @c COLLATE Latin1_General_BIN LIKE '[A-Fa-f]' THEN 'true' ELSE 'false' END AS TestResult

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply