Sort with sql server and sort and unicode

I have a table in sql server, and one of the columns is used to store multilingual data, this is the current nvarchar (250).

When sorting a column on the web interface, I would like to take into account the user's locale, so that the Spanish language was sorted correctly based on "ch".

I lost a little how to do it.

Can someone point me in the right direction.

+3
source share
2 answers

If you are using SQL Server 2005, you can specify the name COLLATION in ORDER BY so that you can build your query dynamically and select the sort name:

[ ORDER BY 
    {
    order_by_expression 
  [ COLLATE collation_name ] 
  [ ASC | DESC ] 
    } [ ,...n ] 
] 

SQL

+2
SELECT ...
FROM Table
WHERE ...
ORDER BY <column> COLLATE Spanish_CI_AI;

, COLLATE. .

+1

Source: https://habr.com/ru/post/1718819/


All Articles