Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get parent elements from SQl SERVER XML datatype column

Status
Not open for further replies.

pikjuo

Programmer
Dec 12, 2000
12
LT
I like shred XML document from SQL SERVER 2005 XML datatype column to relational format with the NODES method.

My XML document may contain three or more nested elements like COMPLEX-> OBJECT-> SUBOBJECT...

With nodes method i can extract nodes element attributes and parent element attributes, as shown below .

select
Colx.query('data(../@objectid)') as objectNumber,
Colx.value('@subobjectID', 'int') as subobjectid
from Complex_XMLTA cross apply XMLdata.nodes('declare default element namespace "XMLTA"; /complex/object/subobject') as Tabx(Colx)

My question is, how to get ancestors for selected node in same manner?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top