XML : Can I query an XML tag without specifying it's parent tags in Sql Server?

I have table column that stores the outgoing XML of an API service. I need to search for all records where for example:

  <personId>1</personId>    

The problem is the parent tags are inconsistent, as the come from different transactions such as:

  <?xml version="1.0" encoding="utf-8"?>  <order>      <personId>1</personId>  </order>    <?xml version="1.0" encoding="utf-8"?>  <query>      <personId>1</personId>  </query>    

Typically, I'd query xml the following way:

  where xmlValue.value('(order/personId)[1]', 'int') = 1    

Is there a way to query the xml values without specifying the parent tags?

No comments:

Post a Comment