سؤال

I'm trying to use PATINDEX function like this:

select PATINDEX('%[A-Z].%', 'he.llo MA. asd ' collate Cyrillic_General_CS_AS)

I expect it returns 9 but it returns 2. Can someone enlight me what's wrong? I also tried to supply collate in first parameter and use Latin1_General_CS_AS instead of Cyrrilic - the same result.

هل كانت مفيدة؟

المحلول

Try forcing a BINARY comparison so it goes bit by bit.

This guys link was helpful in solving your problem. LINK

I duplicated the 2 you were getting and with the COLLATE Latin1_General_BIN it returned the expected 9.

SELECT PATINDEX('%[A-Z].%', 'he.llo MA. asd ' COLLATE Latin1_General_BIN )

نصائح أخرى

Here is my freaky workaround based on this SO thread (in case Matt Akers answer didn't help you):

select PATINDEX('%[ABCDEFGHIJKLMNOPQRSTUVWXYZ].%', 'he.llo MA. asd ' collate Latin1_General_CS_AS)
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top