I am an XML newb and so this relatively small project is causing me grief. I have the XML into a temp table data type XML and that works just fine.
I have found an example of how to then parse the xml into rows and columns however when I have set up a test of just 2 columns - I get 0 results when I am expecting 2 rows.
Can anyone assist please?
DECLARE @XML AS XML, @hDoc AS INT, @SQL NVARCHAR (MAX)
SELECT @XML = xmldata FROM tempXML
EXEC sp_xml_preparedocument @hDoc OUTPUT, @XML
SELECT TransactionType, TransactionDate
FROM OPENXML(@hDoc, 'Handoff/ImmediateDetail')
WITH
(
TransactionType [VarChar](50) '@TransactionType',
TransactionDate datetime '@TransactionDate'
)
EXEC sp_xml_removedocument @hDoc
GO
Sample XML:
<my:Handoff>
<ImmediateDetail OrderItemRef="1032355" TransactionType="Issue"
TransactionDate="2016-09-29T12:22:00></ImmediateDetail>
</my:Handoff>
Cheers
Dave