Home Forums Programming General Weird issue with unicode and pattern matching RE: Weird issue with unicode and pattern matching

  • Right, I think I've found the issue.

    As you can see from this SQLFiddle http://sqlfiddle.com/#!6/7801f/6 (watch out, sqlfiddle doesn't display the char that caused the issue for me in the first place!), in the first recordset there's two columns, the first is a patindex without changing the collation, the second is the same patindex with an enforced "bin" collation.

    You can see that the normal collation doesn't match any characters, but the second does.

    What's more interesting about this is when you look at the second query.

    For for some reason it would seem that the patindex is matching the range, but excluding the hyphen from the characters matched despite the hyphen being within the range selected.

    Unless I'm very much mistaken, this would look like a bug in SQL server.

    As soon as you enforce a binary collation this behaviour goes away.

    Ian.