Solved

how do u store double byte character in MSSQL

Posted on 2001-09-10
6
1,793 Views
Last Modified: 2010-08-05
I'm using MSSQL 2000.

I'm trying to store double byte characters in it.
I created a table with only one field and use varchar (256).

However, it is not able to store the character as it is.
The character is converted into a question mark and store inside.

In the past, when I'm using Informix, I use something
call BLOB. And that works.
Is there an equivalent in MSSQL? Also, BLOB will be
a bit overkill as I'm storing labels like "CD Name",
"Author" etc.

Thanks in advanced.
0
Comment
Question by:slok
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 3

Accepted Solution

by:
ibro earned 100 total points
ID: 6470919
use nvarchar instead of varchar. it will store the string in unicode format (2-bytes per character)
0
 
LVL 3

Author Comment

by:slok
ID: 6470949
I tried the following:

1. create a field with nvarchar 256

2. go to a Chinese website like http://tw.yahoo.com
and copy a Chinese character and paste it into SQL Query
Analyser

3. From SQL Query Analyser, do a insert.
eg. insert into table (Name) values ('??');

4. the query executed without error.

5. However, it shows a question mark inside the
retrieved rows, when I do a retrieved from the table.

How can I verify that it is storing correctly?
0
 
LVL 3

Expert Comment

by:ibro
ID: 6471014
this is a problem of the machine you are working on. Copy/Paste destroys the unicode in inproper - code page. I also have this problem when copy/paste from browser. Try to copy/paste in a text file. So I guess you have to reconfigure your machine to support the characters.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 
LVL 3

Expert Comment

by:ibro
ID: 6471043
btw if you look for equivalent of BLOB - there is. It's can be image, varbinary or binary. Look at BOL to see how to use these datatypes.
hope this helps
0
 
LVL 3

Author Comment

by:slok
ID: 6471093
do you mean installing the input locales for the global
input method?

I have that installed and tried to type in my own
Chinese characters.
Even then, it still shows question marks in it.

I have also tried copying and pasting from a text file
in UTF-8 encoding. It stills shows a question mark.

btw, I'm sticking with nvarchar. BOL/BLOB is overkill in
this case.

I'm going to adjust the points up as I'm asking
quite a fair bit here.
0
 
LVL 3

Author Comment

by:slok
ID: 6471612
I just figure out that Query Analyser doesn't 'supports'
double bytes. ie It doesn't display them properly.


I am able to key in and display in Enterprise Manager.

Thanks
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

717 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question