I have the following XML:
<Field FieldRowId="1000">
<Items>
<Item Name="CODE"/>
<Item Name="DATE"/>
</Items>
</Field>
I need to get the FieldRowId using OPENXML. The SQL i have so far:
INSERT INTO @tmpField
([name], [fieldRowId])
SELECT [Name], --Need to get row id of the parent node
FROM OPENXML (@idoc, '/Field/Items/Item', 1)
EDIT: I added a root node to the xml. and demonstrated grabbing the ID. I'm assuming you have more than one field element in the xml. This is assuming you have the starting XML; are you given an Item and have to traverse upwards?
Using nodes is the way to go.
OPENXML
takes 1/8 of the SQL server memory every time it is used. AlthoughOPENXML
and nodes will generally have the same query performance.