3

When I search with the following query

Select * From [table] WHERE Name like '%Hà Nội T&T%'

in my mssql database I get no results, even though I'm sure it exists in the db.

I seem to have trouble with characters like ộ, ẫ, and Đ.

I have tried changing collation-settings but nothing helps.

Any suggestions?

tobi_dk
  • 33
  • 1
  • 1
  • 5
  • its possibly the [syntax of your query](http://www.w3schools.com/sql/sql_select.asp) .Try `Select * From '%Hà Nội T&T%'` –  May 21 '13 at 11:39
  • the collation is "SQL_Latin1_General_CP1_CI_AS". I have also tried "Vietnamese_CI_AS" – tobi_dk May 21 '13 at 11:44
  • 5
    That column in your table ought to be of type `nvarchar(n)` and then you should query like this: `WHERE Name LIKE N'%Hà Nội T&T%'` - note the leading `N` before the string literal, telling SQL Server that this is a **Unicode** string literal – marc_s May 21 '13 at 11:57
  • that N made the difference - thanks alot. How do I close the thread? – tobi_dk May 21 '13 at 12:11

3 Answers3

5

Try:

Select * From [table] WHERE Name like N'%Hà Nội T&T%'
KristoferA
  • 12,287
  • 1
  • 40
  • 62
0

You need to alter your column containing Vietnamese characters.

ALTER TABLE [table] ALTER COLUMN name NVARCHAR(100) COLLATE Vietnamese_CI_AS

And then do

SELECT * FROM [table] WHERE name LIKE '%Hà Nội%' 

SQL FIDDLE DEMO

Mudassir Hasan
  • 28,083
  • 20
  • 99
  • 133
0

Try changing connection encoding using:

SET character_set_client = charset_name;

Also please do not use Latin1 encoding, try switching to UTF8. Here is a FAQ for Vietnamse Unicode: http://vietunicode.sourceforge.net/main.html

cezar
  • 587
  • 3
  • 10