Blog Stats
  • Posts - 8
  • Articles - 3
  • Comments - 1
  • Trackbacks - 6

 

How to add japanese in a table

Ever wonder what the difference between varchar and nvarchar was? Well I'm still not sure what it is but one thing I discovered today was that to add japanese characters in a database, you have to use the nxxx version datatype.

For example, I have to develop a japanese version of a website I created at work and ended up with a bunch of ??????? instead of the japanese characters in the table I store the content.

To my surprise, the only thing I was missing was the letter 'N'. I changed the datatype of the column containing the content from text to ntext and did something similar to the following:

insert into CMS_MYTABLE (LOCATION, LANGID, REGION, CONTENT)
values ('About', 4, 'Main', N'??????????????????????????????');

Now, when ever I need to add some japanese characters, I just use the 'N' prefix in the string I am inserting.

Simple as 'N'.

  • Share This Post:
  • Share on Twitter
  • Share on Facebook
  • Share on Technorati

Feedback

# re: How to add japanese in a table

Gravatar ROFL!

As you can see, this blog doesn't use the nvarchar or nxxx as datatypes resulting in my japanese characters displaying ???????.

Life is ironic in so many ways. 5/6/2005 2:15 PM | J-F

# re: How to add japanese in a table

Gravatar nvarchar creates fixed-length character fields while varchar creates variable-length fields. Dunno why this is what is needed for Japanese - probably tells the browser that you're using a different character set... Also, if you look at auto-generated drop/create scripts in SQL Server, many of the system tables use nvarchar fields... 5/7/2005 1:34 PM | protected static

# d'oh! Unicode! (was re: How to add japanese in a table)

Gravatar I went and looked it up... Japanese characters require Unicode support - SQL Server supports Unicode in nchar, nvarchar & ntext fields, which would also explain why the system tables use those data types as well. 5/7/2005 1:48 PM | protected static

# re: How to add japanese in a table

Gravatar Ah, that would explain it. Thanks for the info. :) 5/8/2005 10:47 PM | JF

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification:
 
 

 

 

Copyright © Me