0

Idea is to find all values that contains Cyrillic font (russian characters).

Something like:

SELECT CASE 
         WHEN Name LIKE /* Cyrillic font / russian characters */ THEN '1' 
         ELSE Name 
       END AS Filter

I can't find any info about It, so I can't provide what I've tried.

For example:

  Name
Александр -- This is Cyrillic (have russian characters, should return 1)
John      -- This should be returned as normal Name

Have you any ideas?

  • I assume the 'A' is a latin 'A' and not a Cyrillic character with a special code? If you could just search on the first character then it would be a lot easier, as you'd just need to check that char is within the Cyrillic range of Unicode codes, otherwise you'll need to make a loop over each char which will be SLOW – Matt Allwood Jul 24 '15 at 09:40
  • You can use [this Q&A](http://stackoverflow.com/questions/29206404)'s answer to check for ASCII a-zA-Z0-9 – Bernd Linde Jul 24 '15 at 09:41

1 Answers1

2

As per comment:

This Q&A gives a good way of doing this in SQL-Server (Can't mark as duplicate, since it is a different kind of question):

Solution:

select *,                               --  ▼ space added here
       case when TheName like '%[^-A-Za-z0-9 /.+$]%'
         then '1'
         else TheName
      end as 'Filter'
  from CyrillicTest

You can either adjust the RegEx string to match all the Cyrillic characters or adjust it to cater for hyphenated ASCII names (and all other weird things parents put into their kids names). I am not sure about the speed of this against a big table, so please test it.

Testbed:

create table CyrillicTest
     ( TheID   int identity(1,1) not null,
       TheName nvarchar(50)      not null )

insert CyrillicTest
     ( TheName )
values
     ( 'AName' ),
     ( 'Александр' ),
     ( 'CName' )

Output:

TheID       TheName       Filter
----------- ------------- -------------
1           AName         AName
2           Александр     1
3           Thirdname     Thirdname
Community
  • 1
  • 1
Bernd Linde
  • 2,098
  • 2
  • 16
  • 22