hello i am using the following stored procedure to insert the xml data in a table.
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
In this case i am passing the values to parameter as
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>'
The data is inserted , but it is inserted as ????? instead of ** “राज्य “**.
When i am calling the procedure as
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>'
i get the error as “The XML parse error 0xc00ce556 occurred on line number 1, near the XML text “N “
can you please help me out with the issue,as the procedure is called at run time so any data can be passed to the @XmlQue variable.
so how am i supposed to append “N” with the @XmlQue variable ???
Thanks in advance.
The
Nshould come before the xml value.