• Regardless of anything else, when doing string operations of this nature, there are two important best practices to follow:

    • ALWAYS use a binary Collation so that you match the characters you are expecting to match. Otherwise you could match unexpected characters, the set of which varies by Collation. For example, "a" will match other forms of "a" (with and without accents), when using an accent insensitive Collation (i.e. anything with _AI in the name). It is preferable to use a _BIN2 Collation rather than the deprecated _BIN Collations (as of SQL Server 2008), and it is preferable to use the most recent version of the Collation. For anyone using "Latin1_General_*" on SQL Server 2008 or newer, the preferred binary Collation is: Latin1_General_100_BIN2. Luis's code above correctly uses a binary Collation and so is more accurate than the code in the article.
    • It is best to use the NVARCHAR datatype as it is more inclusive and won't lead to data loss. This means also prefixing string literals with a capital "N".

    Take care, Solomon..

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR