query collation on foreign language field in Latin table

十年热恋 提交于 2020-01-05 07:23:33

问题


I have a series of tables that each have a dedicated column to a foreign language. Languages vary from Japanese, Thai, English, Italian, French, more than 20 in all.

All of these tables are set up with Latin Case Insensitive collation. DB works fine.

But now I am trying to query against the specific foreign language column of each table. Lets take Japanese for starters. I'd like a foreign language user to enter foreign text and find the record based on the foreign language column.

  DECLARE @myVar nvarchar(max);

  SET @myVar =  'エンジン ストップ リレー'      = 'Engine Stop Relay' in english

  Select *
  FROM tableJapanese
  WHERE langString = @myVar;

I have tried a multitude of collation combinations. I even copied the table and changed the collation of the column to Japanese_CI_AI and tried to query it that way.

None of these WHERE clauses work on either table/columm collation, when the column was Latin or Japanese...

WHERE lang_String collate Japanese_CI_AI = @myVar;
WHERE lang_String = @myVar collate Japanese_CI_AI;
WHERE lang_String collate Japanese_CI_AI = @myVar collate Japanese_CI_AI;

WHERE lang_String collate Japanese_CI_AI = @myVar;
WHERE lang_String = @myVar collate Japanese_CI_AI;
WHERE lang_String collate Japanese_CI_AI = @myVar collate Japanese_CI_AI;

I would like to leave the columns/database as Latin collation and code the queries for each language if possible.

This seems like one of those problems that if were a snake I'd been bitten already. Can anyone see what I am missing?

MSSQL Express 2008 R2

SOLUTION:

Add N in front of the field, it indicates unicode to SQL...

  Select *
  FROM tblLangJAP_test
  WHERE lang_String = N'エンジン ストップ リレー';

Works flawlessly.

Thanks,


回答1:


Add N in front of the field, it indicates unicode to SQL... Select * FROM tblLangJAP_test WHERE lang_String = N'エンジン ストップ リレー';

Works flawlessly.



来源:https://stackoverflow.com/questions/11676449/query-collation-on-foreign-language-field-in-latin-table

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!