1

I have table with two varchar columns first_name and last_name.

Now I need to convert these columns to nvarchar in order to support UTF-8.

I choose nvarchar datatype in SSMS for these columns and when I try to enter some UTF-8 data, my symbols converts to question marks. For example, if I input йцукен (Ukrainian) it will be converted to ??????.

What is the problem and how to fix it?

Thanks.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user1048261
  • 263
  • 4
  • 15

1 Answers1

5

When you want to insert nvarchar literals into the database table, you must use the N'..' prefix.

So use

INSERT INTO dbo.YourTable(First_Name)
VALUES(N'йцукен')

so that this string will be treated as a unicode string

If you're not using the N'..' notation, you're really inserting a non-unicode string literal - and this will cause these conversions to ?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
  • 1
    Every little helps. This is something we forget everyday... +1 – Kaf Feb 20 '13 at 16:46
  • Unfortunately, it doesn't work in my case. It display question marks even when I try to update table with 'N' character. For example, UPDATE mytable SET first_name=N'йцукен' WHERE id='10' will save question marks as before. In spite of this, when I create new table with nvarchar columns, everything works fine. – user1048261 Feb 21 '13 at 09:25