Error while parsing XML through OPENXML

meztikp

New Member
I have an XML of 55MB and is trying to shred it using OPENXML as it seems to be faster than normal XML shredding. The structure of XML is like this :\[code\]<DATA_EXPORT><HEADER> <RECDATE> <START>2011-03-16</START> <END>2012-02-10</END> </RECDATE> <SOME_COUNT>10288</SOME_COUNT> <QUESTION_MAP> <QUESTION> <SERVICE>OU</SERVICE> <VARNAME>UNIT</VARNAME> <QUESTION_TEXT></QUESTION_TEXT> </QUESTION> 250 more nodes like <QUESTION> </QUESTION_MAP></HEADER><SOMENODES> <SURVEY_ID>448817197</SURVEY_ID> <CLIENT_ID>58</CLIENT_ID> <SERVICE>OU</SERVICE> <RECDATE>2011-03-29</RECDATE> <DISDATE>2010-03-29</DISDATE></SOMENODES> : : 1000s of nodes like <SOMENODES></DATA_EXPORT>\[/code\]And I am using following query for getting the data out of the nodes\[code\]declare @xmlData varchar(max) = null ,@iDoc int = null ,@xml xml = nullselect @xmlData = http://stackoverflow.com/questions/11423637/cast(@xml as varchar(max)) exec sp_xml_preparedocument @iDoc OUTPUT, @xmlData select * ,getdate() from openxml(@iDoc,'//DATA_EXPORT/SOMEDATA', 2) with ( surveyId varchar(50) 'SURVEY_ID[1]', clientId int 'CLIENT_ID[1]', [service] varchar(50) 'SERVICE[1]', recieveDate datetime 'RECDATE [1]', dischargeDate datetime 'DISDATE [1]' ) option (optimize for unknown)\[/code\]I have wrritten this is stored procedure and am getting following error:\[code\]The XML parse error 0xc00ce562 occurred on line number 1, near the XML text "<".Msg 6602, Level 16, State 2, Procedure sp_xml_preparedocument, Line 1The error description is 'A declaration was not closed.'.Msg 8179, Level 16, State 5, Procedure q_ImportSurveyMasterDetails, Line 81Could not find prepared statement with handle 0.The statement has been terminated.\[/code\]Can anybody help me what is the error in line number as indicated by the error?? Also is there any better and faster way to shred a 55MB XML file??Thanks in advance.
 
Back
Top