Chinese character gash when using SQLAPI++

133 Views Asked by At

I use SQLAPI++ to insert data into SQL Server 2005. When there are many Chinese characters, it will be garbled in database.

IDE : MS 2005

IDE Character Set : Multi-Byte

SQLAPI Lib : sqlapi.lib(dynamic release import library for MSVC++)

1

There are 1 best solutions below

2
On

If what you are looking for is a way to store the Chinese Characters in SQL Server database, Then you should Try storing the same into an NVARCHAR field. also, prefix the Caracter N (Case sensitive) before the string. Like this

DECLARE @T TABLE
(
    StrChar VARCHAR(50),
    StrChar2 VARCHAR(50),
    StrNVar NVARCHAR(100),
    StrNVar2 NVARCHAR(100)
)

INSERT INTO @T
VALUES('诶',N'诶','诶',N'诶')

SELECT
    *
    FROM @T

I got the result like this

enter image description here