Click here to Skip to main content
15,893,622 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

I have a table in SQL Server 2008 which contains string in various format for e.g. ASCII,UTF-8 etc.I need to read this string in unicode format.

Is there any direct query like collate... or anything else to solve this.

Please share your solution.

Reagrds,
Sachin
Posted

That depends on how your data is stored in SQL Server. All unicode data must be stored in columns with datatype N(type) e.g. nvarchar, ntext, nchar

Look at MSDN documentation:

http://msdn.microsoft.com/en-us/library/aa933104(v=sql.80).aspx[^]
 
Share this answer
 
Comments
Prasad_Kulkarni 12-Jun-12 8:23am    
5'ed!
cancerion 12-Jun-12 8:28am    
Actually in table data can be stored in utf-8 ,ascii ,unicode or any other format , it will not surely in 1 format, so just we want to make sure when retreiving using stored procedure we get in unicode format.
C# (and .Net in general) handle unicode strings transparently, you won't have to do anything special unless your application needs to read/write files with specific encodings.

Strings in C# are Unicode by default. Try
C#
string converted = Encoding.Unicode.GetString(data);

where data is a byte[] array containing your Unicode data. If your data is big endian, you can try
C#
string converted = Encoding.BigEndianUnicode.GetString(data);

Have a look on similar discussions;
C# read unicode[^]
Unicode & C#[^]
 
Share this answer
 
Comments
cancerion 12-Jun-12 8:35am    
Thanks for reply..

Actually i am looking for a solution at sql server level,we perform some operation on unicode data. some query to get column values saved in different formats into unicode format.
cancerion 13-Jun-12 2:19am    
Hello,


in a table i have data is utf-8 format for e.g.
Carrer de Béjar
Calle de Antonio Machado
Calle del Canónigo Domenech
Carrer de Pau Arpí i Galí
Calle del Abad Oliba

I want them to read in unicode format ,In database in extended property collation is set as 'SQL_Latin1_General_CP1_CI_AS'

Regards,
Sachin

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900