Solved

how do u store double byte character in MSSQL

Posted on 2001-09-10
6
1,716 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
Comment Utility
use nvarchar instead of varchar. it will store the string in unicode format (2-bytes per character)
0
 
LVL 3

Author Comment

by:slok
Comment Utility
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
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 3

Expert Comment

by:ibro
Comment Utility
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
Comment Utility
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
Comment Utility
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
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.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now