How to identify unicode text in sql?

后端 未结 2 1825
不知归路
不知归路 2021-01-07 09:08

Table1 has nvarchar column called umsg which contains unicode text and some time english also.

I want to find out English text present in umsg column.



        
2条回答
  •  一整个雨季
    2021-01-07 09:42

    check below :

    ;WITH CTE
     AS (
     SELECT ID,
            DATE,
            umsg,
            CASE
                WHEN(CAST(umsg AS VARCHAR(MAX)) COLLATE SQL_Latin1_General_Cp1251_CS_AS) = umsg
                THEN 0
                ELSE 1
            END HasSpecialChars
     FROM )
     SELECT ID,
            DATE,
            umsg
     FROM CTE
     WHERE Date >= '01/01/2014'
           AND Date < '09/26/2017'
           AND HasSpecialChars = 0;
    

    Desired Output :

    ID  DATE                     umsg
    1   2017-09-12 00:00:00.000  The livers detoxification processes.                                                                     
    2   2017-09-11 00:00:00.000  Purposely added 1      
    

    Hope, it will help you.

提交回复
热议问题