AuthenticReplica
AuthenticReplica

Reputation: 880

Microsoft SQL Server database character conversion

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?

Upvotes: 1

Views: 176

Answers (2)

marc_s
marc_s

Reputation: 755471

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.

Upvotes: 1

Evaldas Buinauskas
Evaldas Buinauskas

Reputation: 14097

You need different collation.

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

Upvotes: 0

Related Questions