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

前端 未结 8 1498
春和景丽
春和景丽 2020-12-01 12:18

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 add         


        
8条回答
  •  無奈伤痛
    2020-12-01 12:28

    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
    

提交回复
热议问题