Using PATINDEX and a case-sensitive collation to search for upper-case letters in a string I noticed this was not yielding the desired result:
-- returns 1
SELECT PATINDEX('%[A-Z]%'
, 'abCde' COLLATE SQL_Latin1_General_Cp1_CS_AS);
however, specifying every letter, A-Z, does:
-- returns 3
SELECT PATINDEX('%[ABCDEFGHIJKLMNOPQRSTUVWXYZ]%'
, 'abCde' COLLATE SQL_Latin1_General_Cp1_CS_AS);
Is my understanding of using a range in the first case incorrect? Why is the behaviour like this?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…