Find ONLY Capital Letters in word through IN SQL Server query

前端 未结 5 794
名媛妹妹
名媛妹妹 2020-12-11 19:50

I have to do this in SQL Server

I have data such as

Belo Horizonte , MG - Brazil
São Paulo , SP - Brazil
Barueri , SP - Brazil
Ferraz de Vasconcelos          


        
5条回答
  •  伪装坚强ぢ
    2020-12-11 20:19

    Collation matters. You need to add Collate to your query, such as:

    Select * from table where exists (Select SUBSTRING(ADDRESS_BLOCK,PatIndex('% [A-Z][A-Z] %',ADDRESS_BLOCK),3) from table)
    COLLATE Latin1_General_CS_AS_KS_WS ASC;
    

    You may need a difference collation - your current one is clearly case insensitive. You can find you current collation, and replace Latin1_General_CS_AS_KS_WS with the one you need, replacing the CI with CS, to get the case senstive version of your current collation.

    See: http://msdn.microsoft.com/en-us/library/ms184391.aspx

提交回复
热议问题