Solved

how do u store double byte character in MSSQL

Posted on 2001-09-10
6
1,774 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
Independent Software Vendors: 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!

 
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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

726 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