I was trying to read data of concerned columns from XML given below and load into database.
My XML is like below:
<questions>
<question>
<Field name="id">12</Field>
<Field name="lid">10</Field>
<Field name="text">Hello</Field>
</question>
</questions>
I have table with columns id,lid and text , i want to load data from above xml into database. Try to use OpenXML but in vain.not able to read attribute.
I was using below query.
DECLARE @doc AS INT
EXEC Sp_xml_preparedocument
@doc OUTPUT,
@queueData
INSERT INTO dbo.Questions
([Id],[Lid],[Text])
SELECT * FROM OPENXML(@doc, '/questions/question/Field', 1)
WITH ( id VARCHAR(20),
lid VARCHAR(20) ,
text VARCHAR(MAX))
i want to load data from above xml into database. Try to use OpenXML but in vain.not able to read attribute.
ANY Help appreciated!!
Thank you!!