Search code examples
sqlsql-servercollate

how to upper a column with collate in SQL SERVER


We are doing an integration between two software, I am trying to convert a column to uppercase in select statement but Turkish characters get converted wrong. Iknow to use "collate" in where clause but can I use it in "select upper(col1) from ..."

here is how I use collate it in "where"

WHERE Column1 COLLATE Latin1_General_CS_AS = 'casesearch'

but I dont know how to use it in

select upper(col1) from ...

can anybody give me a clue?


Solution

  • Apparently @Ömer had given the answer in the comments. I just quoted from him. Credits belong to him.

    Tested and worked.

    SELECT
        *
    FROM
        TheTable
    WHERE
        UPPER(CAST(Column1 COLLATE Latin1_General_CS_AS AS VARCHAR(255))) = UPPER(CAST('casesearch' COLLATE Latin1_General_CS_AS AS VARCHAR(255))))
    

    Or for just select expression:

    SELECT
        UPPER(CAST(Column1 COLLATE Latin1_General_CS_AS AS VARCHAR(255)))
    FROM
        TheTable