Original: SQL Server garbled after inserting Chinese data
In the course of doing the project today, I encountered a problem with the title, such as:
The database uses the SQL Server2012 version, and the script to create the table is as follows:
CREATE TABLE [dbo]. [Type]
(
[TypeId] INT not NULL PRIMARY KEY,
[TypeName] NVARCHAR (+) Not NULL,
[Description] NVARCHAR (255) Null
[CategoryId] INT not NULL DEFAULT 0
)
Depending on the solution mentioned in some related documents, a field containing Chinese data is required, is generally defined as Nchar/nvarchar data type . However, in practice, even if the database table field is defined, it will produce garbled characters. Another solution was attempted: When adding Chinese data, before the inserted text character, the script example is as follows:
MERGE dbo. [Type] As Target
USING (
SELECT 0, n' other ', n' undefined consumption category ', 0
UNION
SELECT 1, n' staple food ', n' m, noodles, oil, salt, etc. ', 1
UNION
SELECT 2, n' staple food ', n' meat, vegetables, eggs, deli, etc. ', 1
UNION
SELECT 3, n' dining ', n' with dine-in delivery ', 1
UNION
SELECT 4, N' drinks ', ', 2
It is verified that this scheme can solve Chinese garbled problem.
garbled text after SQL Server inserts Chinese data