您好,我正在使用以下存储过程将 xml 数据插入表中。
PROCEDURE [dbo].[ExpertSystem_SET_QuestionData]
@XmlQue NVARCHAR(MAX)
AS
set nocount on
DECLARE @XmlHdl INT
BEGIN
SET @XmlQue=N''+@XmlQue
EXEC sp_xml_preparedocument @XmlHdl OUTPUT,@XmlQue
INSERT INTO ExpertSystem_Master
SELECT QIdx,@TemplateId,QDetailsx,IsYesx,IsNox,Eligibleyesx,Eligiblenox,0,0
FROM
OPENXML(@XmlHdl,'/Template/QueInfo',1)
WITH
( QIdx INT '@QId',
QDetailsx Ntext '@QDetails',
IsYesx Ntext '@IsYes',
IsNox Ntext '@IsNo',
Eligibleyesx CHAR(1) '@Eligibleyes',
Eligiblenox CHAR(1) '@Eligibleno'
)
END
在这种情况下,我将值传递给参数
ExpertSystem_SET_QuestionData '<?xml version="1.0" encoding="UTF-16"?><Template TId="1"><QueInfo QId="1" QDetails="Are you " IsYes="Yes" IsNo="No" Eligibleyes="Y" Eligibleno="N"/><QueInfo QId="2" QDetails=" राज्य " IsYes="Yes" IsNo="No" Eligibleyes="Y" Eligibleno="N"/><QueAns QId="1" isMsgFlag="N" Msg="you are not Eligible"/><QueAns QId="2" isMsgFlag="N" Msg="you are not eligible"/></Template>'
数据已插入,但插入为????? 而不是**“राज्य”**。
当我将程序称为
ExpertSystem_SET_QuestionData 'N<?xml version="1.0" encoding="UTF-16"?><Template TId="1"><QueInfo QId="1" QDetails="Are you Domicile of maharashtra" IsYes="Yes" IsNo="No" Eligibleyes="Y" Eligibleno="N"/><QueInfo QId="2" QDetails="Have you passed Secondary School 10th Examination?महाराष्ट्र राज्य मार्ग परिवहन महामंडळ " IsYes="Yes" IsNo="No" Eligibleyes="Y" Eligibleno="N"/><QueAns QId="1" isMsgFlag="N" Msg="you are not Eligible"/><QueAns QId="2" isMsgFlag="N" Msg="you are not eligible"/></Template>'
我收到错误消息“XML 解析错误 0xc00ce556 发生在第 1 行,靠近 XML 文本“N”
你能帮我解决这个问题吗,因为该过程是在运行时调用的,所以任何数据都可以传递给@XmlQue 变量。那么我应该如何在@XmlQue 变量中附加“N”???
提前致谢。