Why is sql server storing question mark characters instead of Japanese characters in NVarchar fields?

I'm trying to store Japanese characters in nvarchar fields in my SQL Server 2000 database.

When I run an update statement like:

update blah 
set address = N'スタンダードチャ'
where key_ID = 1

from SQL Server Management Studio, then run a select statement I see only question marks returned to the results window. I'm seeing the same question marks in the webpage which looks at the database.

It seems this is an issue with storing the proper data right? Can anyone tell me what I need to do differently?


This cannot be a correct answer given your example, but the most common reason I've seen is that string literals do not need a unicode N prefix.

So, instead of

set address = N'スタンダードチャ'

one would try to write to a nvarchar field without the unicode prefix

set address = 'スタンダードチャ'

See also: N prefix before string in Transact-SQL query


I was facing this same issue when using Indian languages characters while storing in DB nvarchar fields. Then i went through this microsoft article -

http://support.microsoft.com/kb/239530

I followed this and my unicode issue got resolved.In this article they say - You must precede all Unicode strings with a prefix N when you deal with Unicode string constants in SQL Server

SQL Server Unicode Support

SQL Server Unicode data types support UCS-2 encoding. Unicode data types store character data using two bytes for each character rather than one byte. There are 65,536 different bit patterns in two bytes, so Unicode can use one standard set of bit patterns to encode each character in all languages, including languages such as Chinese that have large numbers of characters.

In SQL Server, data types that support Unicode data are:

nchar
nvarchar
nvarchar(max) – new in SQL Server 2005
ntext

Use of nchar, nvarchar, nvarchar(max), and ntext is the same as char, varchar, varchar(max), and text, respectively, except:

- Unicode supports a wider range of characters.
- More space is needed to store Unicode characters.
- The maximum size of nchar and nvarchar columns is 4,000 characters, not 8,000     characters like char and varchar.
- Unicode constants are specified with a leading N, for example, N'A Unicode string'

APPLIES TO

Microsoft SQL Server 7.0 Standard Edition
Microsoft SQL Server 2000 Standard Edition
Microsoft SQL Server 2005 Standard Edition
Microsoft SQL Server 2005 Express Edition
Microsoft SQL Server 2005 Developer Edition
Microsoft SQL Server 2005 Enterprise Edition
Microsoft SQL Server 2005 Workgroup Edition