Coba ini:Anda perlu menyusun kolom DAN menentukan huruf kapital. Ekspresi reguler [A-Z] tidak peka huruf besar/kecil, bahkan jika Anda menentukan urutan susunan.
SELECT SUBSTRING(
ADDRESS_BLOCK
, PatIndex(
N'% [ABCDEFGHIJKLMNOPQRSTUVWXYZ][ABCDEFGHIJKLMNOPQRSTUVWXYZ] %'
, ADDRESS_BLOCK COLLATE sql_latin1_general_cp1_cs_as
)
, 3
)
FROM
(
SELECT 'Belo Horizonte , MG - Brazil' ADDRESS_BLOCK
UNION
SELECT 'São Paulo , SP - Brazil'
UNION
SELECT 'Barueri , SP - Brazil'
UNION
SELECT 'Ferraz de Vasconcelos , SP - Brazil'
) n