Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


SELECT FROM OpenXML not returning any data


SELECT FROM OpenXML not returning any data

Author
Message
Jacobus-785651
Jacobus-785651
Old Hand
Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)Old Hand (308 reputation)

Group: General Forum Members
Points: 308 Visits: 249
I have the following challenge.
I would like to parse XML data into a relational table.

<NSTRoot xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://volvo.com/vss/4_0/v1_0">
<Header>
<General>
<MsgID>2d981758-3718-4ea0-8740-1f2faa788c2c</MsgID>
<TimeStamp>2013-04-24T07:27:53.7190466Z</TimeStamp>
</General>
</NSTRoot>

This is just a small part of the XML File.

I am using the following statement:
DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)

SELECT @XML = XMLData FROM tblTQ

select @XML

EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML


SELECT MsgID,TimeStamp
FROM OPENXML(@hDoc, '/Header/General')
WITH
(
MsgID Uniqueidentifier '@MsgID',
TimeStamp datetime '@TimeStamp'

)


EXEC sp_xml_removedocument @hDoc
GO

There are no results What am i doing wrong?

Hehe
Jonathan Mallia
Jonathan Mallia
Ten Centuries
Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)Ten Centuries (1K reputation)

Group: General Forum Members
Points: 1033 Visits: 1287
Hi,

I think you must insert the namespace near
FROM OPENXML(@hDoc, '/Header/General')




Jon
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search