• gerry anderson (11/22/2013)


    I gave the example a try, mychar LIKE '[a-z]dam' returns only Bdam. While mychar like '[A-Z]dam' returns Adam and Bdam. Is this a result of the version/flavor of SQL?

    No, it's a result of the collation you use. I'm guessing that the defauult collation for the column you tested this on is case sensitive. In most case sensitive collations, capitals sort first. So A comes first, then a, then B, then b, etc. That's why 'A' is included in [A-Z] but not in [a-z] - because the capital A comes before the small a, which is the starting point for the second LIKE patters.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/