我正在解析JSON文件中的数据,当我最终将其加载到表中时遇到了问题,该数据中包含ñ等特殊字符的数据显示为ñ。
代码在NVARCHAR中,我不确定为什么不能正确提取
INSERT INTO @recordsInfo
(
messageId,
messageType,
messageVariation,
windowEnvelope,
recipientFirstName,
recipientLastName,
recipientAddressLine1,
recipientAddressLine2,
recipientCity,
recipientState,
recipientZip,
recipientZipSuffix
)
SELECT messageId,
messageType,
messageVariation,
windowEnvelope,
recipientFirstName,
recipientLastName,
recipientAddressLine1,
recipientAddressLine2,
recipientCity,
recipientState,
recipientZip,
recipientZipSuffix
FROM
OPENJSON(@ValueR)
WITH
(
messageId NVARCHAR(100),
messageType NVARCHAR(100) '$.messageDetails.messageType',
messageVariation NVARCHAR(100) '$.messageDetails.messageVariation',
windowEnvelope NVARCHAR(100) '$.messageDetails.windowEnvelope',
recipientFirstName NVARCHAR(100) '$."shippingDetails"."recipientFirstName"',
recipientLastName NVARCHAR(100) '$."shippingDetails"."recipientLastName"',
recipientAddressLine1 NVARCHAR(1000) '$.shippingDetails.recipientAddressLine1',
recipientAddressLine2 NVARCHAR(100) '$.shippingDetails.recipientAddressLine2',
recipientCity NVARCHAR(100) '$.shippingDetails.recipientCity',
recipientState NVARCHAR(100) '$.shippingDetails.recipientState',
recipientZip NVARCHAR(100) '$.shippingDetails.recipientZip',
recipientZipSuffix NVARCHAR(100) '$.shippingDetails.recipientZipSuffix'
);
DECLARE @recordsInfo TABLE
(
RecID INT IDENTITY(1, 1),
messageId NVARCHAR(100),
messageType NVARCHAR(100),
messageVariation NVARCHAR(100),
windowEnvelope NVARCHAR(100),
recipientFirstName NVARCHAR(100),
recipientLastName NVARCHAR(100),
recipientAddressLine1 NVARCHAR(1000),
recipientAddressLine2 NVARCHAR(100),
recipientCity NVARCHAR(100),
recipientState NVARCHAR(100),
recipientZip NVARCHAR(100),
recipientZipSuffix NVARCHAR(100)
);
RecipientFirstName是我正在查看的主要
答案 0 :(得分:1)
JSON通常是UTF-8。只有在2019版中,SQL Server才能理解UTF-8,因此在此之前,您必须手动进行操作。