I need help with xQuery syntax.
I have a table with a column declarde with the SQLType xml.
My table I would like to create a sql query, using xQuery, to retrieve table records where the xml contains any element, in the xPath, where it's attribute parameterCode = "a specific string"
The xPath is: LoggedProductInfo/LoggedParameterInfo/LoggedDiagnosticObject/DiagnosticObject/TEA2Plus/@parameterCode
The xml is complex, contains sequence, choice etc. My schema
I'm pretty good at SQL, but when it comes to xQuery I'm lost, so I would appreciate any help I could get.
From comments
if I use
select a.ReadingId ,
a.message_xml.exist('LoggedProductInfo/LoggedParameterInfo/LoggedDiagnosticObject/DiagnosticObject/TEA2Plus[@parameterCode = "P1ASV"]')
AS parameterCodeExists
from MyTable a
The value returned for column parameterCodeExists is 0, even if I know there is such a parameterCode.
flag
If I copy the xPath from the xml I'll have the following:
/lpi:LoggedProductInfo/lpi:LoggedParameterInfo/lpi:LoggedDiagnosticObject[1]/lpi:DiagnosticObject/lpi:TEA2Plus/@parameterCode
Can it be something special one would need to do due to that lpi:LoggedDiagnosticObject1 is a list?