1

I have a database imported that contains Arabic characters but are displayed as question marks. Through some searching I found that the column data types should be nvarchar to support unicode (they were varchar). I changed one of the columns that contains those characters to nvarchar but the data is still displayed as "??". How can I change the existing values to become unicode and display correctly?

2 Answers 2

1

You cannot just simply change the datatype to nvarchar - that won't bring back the data since it's already been "destroyed" by having been converted to a non-Unicode format.

You need to use nvarchar and then you need to insert (or update) the data in such a way that doesn't convert it back to ANSI codes.

If you use T-SQL to insert that Unicode code, make sure to use the N'...' prefix:

INSERT INTO dbo.YourTable(NvarcharCol)
VALUES (N'nvarchar-value')

From a front-end language like C# or PHP or Ruby, make sure to use Unicode strings - .NET (C# and VB.NET) does that automatically. When using queries with parameters, make sure to specify Unicode string types for those relevant parameters.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for that. I don't really have that option but I have a backup of the database before I changed the field to unicode. Could I do anything with that to convert the characters to unicode?
@TarekMerachli: unfortunately, no - once you've inserted the Unicode characters into the 1-byte-per-character varchar, the information these characters had is gone. No way to just magically make it reappear.
0

You need different collation.

Read more here: https://msdn.microsoft.com/en-us/library/ms143508.aspx

1 Comment

I also changed the database collation to Arabic_CI_AS but still not changing the displayed characters

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.