KhanhQuach
KhanhQuach

Reputation: 153

Convert varchar to nvarchar

My company use sql server 2000 to store data . There is a table with a column named 'Vattu' . The problem is that : this column declare as varchar data type , however it's save both unicode and anscii value !

So every time I show this column data on web , it show unreadable characters. Is there any way to convert data to unicode value using c# ?

Upvotes: 0

Views: 1765

Answers (2)

Aaron Bertrand
Aaron Bertrand

Reputation: 280625

You need to change the data type of the column to nvarchar in order to store Unicode data.

The Unicode data you've already tried to store in the column is gone - you can't magically get it back, unless your application logged the data or you were running traces of all commands and still have access to those.

Upvotes: 0

Amit Rai Sharma
Amit Rai Sharma

Reputation: 4225

A quick google search would have given you the answer. Anyway you use System.Text.Encoding to encode the ascii to unicode. check the sample code at Encoding.Convert Method

Also converting the column datatype to NVarchar will be better in long run. Doing so you will save CPU processing that you will be using due to conversion at c# level.

Upvotes: 1

Related Questions