Solved

how do u store double byte character in MSSQL

Posted on 2001-09-10
6
1,761 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
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

809 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