user1136875
user1136875

Reputation: 613

Sql queries on string columns - sorting according to language

I have a column of name, varchar(200). In this column data can be filled in hebrew and english.

I have code that does queries on this DB, I want to have the option to sort the results - first hebrew and then english - and the other way as well.

How can it be done? if at all...

Upvotes: 1

Views: 1000

Answers (1)

Andomar
Andomar

Reputation: 238116

This would sort any name with a Hebrew character on top, and in Hebrew order. The other names would be sorted in English order:

select  *
from    YourTable
order by
        case 
        when name like '%[... all hebrew letters here ...]%' then name
        end collate Hebrew_CI_AS
,       name collate Latin1_General_CI_AS

In a collation, CI means Case Insensitive. AS means Accent Sensitive.

Upvotes: 3

Related Questions