1

I'm cleaning up a SQL Server 2012 database which contains some nvarchar columns containing mixed character set data (Latin and Thai script). For example:

enter image description here

As I have a number of columns with the same TariffDescription text, I want to apply a translation using a simple UPDATE command. For example:

UPDATE Tariff.NationalTariff 
SET TariffDescription = 'Liquid.' 
WHERE TariffDescription = 'Thai description: - - ที่มีสภาพเหลว';

However, when I execute this command, SQL Server is not updating any rows. I confirmed that the problem is with the WHERE clause by attempting to do a simple select:

SELECT * 
FROM Tariff.NationalTariff 
WHERE TariffDescription = 'Thai description: - - ที่มีสภาพเหลว';

This query returns zero rows when I expected it to return around a hundred or so.

Note that I populated the WHERE clause string by copying and pasting from the Results table (using a query that does not rely on the TariffDescription column). I cannot type in Thai characters.

I have no idea why this is happening and my best guess is that it has something to do with mixing together character sets. Any ideas?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Mark Micallef
  • 2,643
  • 7
  • 28
  • 36

1 Answers1

2

Place N before the literal text

   SELECT * FROM Tariff.NationalTariff WHERE TariffDescription = N'Thai description: - - ที่มีสภาพเหลว';
radar
  • 13,270
  • 2
  • 25
  • 33
  • Yes, this fixes the problem. Thank-you. I did a quick google on the N prefix before a string in T-SQL which designates it as an NVARCHAR string. – Mark Micallef Oct 14 '14 at 01:46
  • 1
    https://stackoverflow.com/questions/10025032/what-is-the-meaning-of-the-prefix-n-in-t-sql-statements – Mark Micallef Oct 14 '14 at 01:47