问题
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